如何用matlab绘制分段函数图像 下图分段函数图像用matlab怎么画出来?
\u7528matlab\u600e\u6837\u753b\u5206\u6bb5\u51fd\u6570\u56fe1\u3001\u9996\u5148\u53cc\u51fb\u6253\u5f00MATLAB\u8f6f\u4ef6\uff0c\u5982\u56fe\u6240\u793a\u3002
2\u3001\u7136\u540e\u5efa\u7acb\u4e00\u4e2a\u811a\u672c\u6587\u4ef6\uff0c\u5177\u4f53\u65b9\u6cd5\u5982\u56fe\u6240\u793a\u3002
3\u3001\u7136\u540e\u5b9a\u4e49\u53d8\u91cf\u3002
4\u3001\u7136\u540e\u5efa\u7acb\u5faa\u73af\uff0c\u6c42\u89e3\u5206\u6bb5\u51fd\u6570\u3002
5\u3001\u7136\u540e\u91c7\u7528\u4ee5\u4e0b\u6307\u4ee4\u753b\u56fe\u3002
6\u3001\u7136\u540e\u5c31\u53ef\u4ee5\u770b\u5230\u753b\u51fa\u7684\u56fe\u7247\u5982\u56fe\u6240\u793a\u3002
\u5bf9\u4e8e\u5206\u6bb5\u51fd\u6570\u56fe\u50cf\uff0c\u7528matlab\u7ed8\u5236\u53ef\u4ee5\u8fd9\u6837\u5b9e\u73b0\u3002
fun=@(x)0.*(x=0 & x100)
x=-20:10:150;
y=fun(x);
plot(x,y)
fplot(@(x) exp(x),[-3,0],'b');
hold on;
fplot(@(x) cos(x),[0 3],'b');
hold off;
grid on;
绛旓細棰樹富缁欏嚭杩欎釜鍒嗘鍑芥暟濡備綍鐢╩atlab缁樺埗鍏跺浘褰紵缁樺埗鍏朵簩缁村浘褰㈢殑鏂规硶鏈夊緢澶氾紝濡俻olt鍑芥暟锛堝凡鐭ュ悜閲忔暟鍊肩粯鍒跺浘褰 锛夛紝fplot鍑芥暟锛堝凡鐭鍑芥暟缁樺埗鍥撅級锛宔zplot鍑芥暟锛堝凡鐭ヨ〃杈惧紡缁樺埗鍥惧舰 锛夈傚鐢╢plot鍑芥暟鏉ョ粯鍒跺叾鍥惧舰锛屾垜浠彲浠ュ仛锛1銆侀鍏堟垜浠嚜瀹氫箟鍒嗘鍑芥暟锛屽彲浠ョ敤鍙ユ焺鍑芥暟@(x)銆佷篃鍙互鐢ㄥ尶鍚嶅嚱鏁癷nline鎴栧嚱鏁...
绛旓細鐢╩atlab缁樺埗鍒嗘鍑芥暟鍥惧儚(piecewise function)锛屾渶绠鍗曠殑鏂规硶鏄娇鐢╢plot鍑芥暟鍜屽尶鍚嶅嚱鏁帮紝濡備笅5琛屼唬鐮佹墍绀猴細fplot(@(x) exp(x),[-3,0],'b');hold on;fplot(@(x) cos(x),[0 3],'b');hold off;grid on;
绛旓細鐢╩atlab鐢诲垎娈靛嚱鏁鏇查潰鍥撅紝鍙互鍏堣嚜瀹氫箟鍒嗘鍑芥暟p=func(x1锛寈2)锛屽啀鐢╩eshgrid锛堬級鍑芥暟灏唜1,x2缃戞牸鍖栵紝鍐嶆眰鍑簆鍊硷紝鏈鍚庣敤mesh(x1锛寈2锛宲)鍛戒护缁樺嚭鍏舵洸闈㈠浘銆傜紪绋嬪悗杩愯鍙揪鍒板涓嬪浘褰
绛旓細浣跨敤m鍑芥暟鏂囦欢锛屽疄鐜鍒嗘缁樺埗鏇茬嚎锛岀粯鍒剁殑鍚勬潯鏇茬嚎涓轰竴涓瓙鍑芥暟銆傝繖涓棶棰樺彲浠ヨ繖鏍锋潵澶勭悊銆1銆佸缓绔嬩笁涓瓙鍑芥暟锛屽嵆 function y1=func1(x)y1=0.5*exp(-3.75*x.^2-1.5*x);end function y2=func2(x)y2=0.7*exp(-6*x.^2);end function y3=func3(x)y3=0.5*exp(-3.75*x.^2+1....
绛旓細1銆佷笌寤虹珛M鏂囦欢绫讳技锛屽湪鍛戒护绐楀彛涓緭鍏dit銆2銆佺紪鍐鍑芥暟锛岄渶瑕佹敞鎰忓嚱鏁板懡鍚嶈鍒欙紝娉ㄩ噴閮ㄥ垎鍙湁鍙棤锛岀敤%寮濮嬨3銆佺紪鍐欏畬鎴愬悗淇濆瓨鏂囦欢锛屾渶濂戒繚瀛樺湪褰撳墠宸ヤ綔璺緞鐨勬枃浠跺す銆4銆佺洿鎺ヨ緭鍏ュ嚱鏁板悕锛屽舰鍙傦紝灏辫兘杩斿洖璁$畻缁撴灉銆5銆佸拰鏌ョ湅鍏跺畠鍑芥暟璇存槑涓鏍凤紝杈撳叆鈥渉elp 鍑芥暟鍚嶁 灏辫兘鐪嬪埌杩欎釜鍑芥暟鐨勬敞閲婅鏄庛
绛旓細鍒嗘鍑芥暟鐨缁樺埗鏂规硶鏈変笅闈㈠嚑绉嶏細鏂规硶涓锛屽垎娈靛垎鍒敾锛岀劧鍚庣敤hold on灏嗗浘鍍忎繚鎸佸湪鍚屼竴涓猘xes涓%淇濇寔鍦ㄥ悓涓涓潗鏍囪酱涓繕鍙互鐢╯et(gca,'Nextplot','Add')鍛戒护x1 = linspace(0,1,30);y1 = x1;x2 = linspace(1,2,30);y2 = x2.^2;plot(x1,y1)hold on%鎴栬% set(gca,'Nextplot','Add'...
绛旓細matlab瀵鍒嗘鍑芥暟鏈夐潪甯哥畝鍗曠殑琛ㄧず锛屽姝や緥鑰岃█锛岃鍙ュ涓嬶細x = -5:.1:5;y = (3*x.^2+1).*(x>=1) + (2-x.^3).*(x<=-1);瀵逛簬妤间富鐨勭▼搴忥紝閿欒涔嬪鍦ㄤ簬锛歟lseif -1<x<1 搴旇涓 elseif -1<x & x<1 涔熷氨鏄 涓嶇瓑寮忎覆 蹇呴』琛ㄨ揪涓 鍗曚釜鐨勪笉绛夊紡鐨勨滀笖鈥濆叧绯汇傛病娉ㄦ剰鍒 ...
绛旓細瀵逛簬鍒嗘鍑芥暟鍥惧儚锛鐢╩atlab缁樺埗鍙互杩欐牱瀹炵幇銆俧un=@(x)0.*(x<0)+x/100.*(x>=0 & x<=100)+1.*(x>100)x=-20:10:150;y=fun(x);plot(x,y)
绛旓細寤虹珛鍚嶄负myfun.m鐨刴鏂囦欢锛屽唴瀹瑰涓嬶細function f=myfun(x)f=0.5*x.*(x<=2)+(1.5-0.25*x).*(x>2).*(x<=6)+0.5*(x>6);涔嬪悗缁樺埗[0,2]鍐 f锛坸锛*f锛坸+2锛夌殑鏇茬嚎 x=0:.1:2;y=myfun(x).*myfun(x+2);plot(x,y)缁樺埗f(x)鐨勬洸绾 x=0:.1:10;y=myfun(x);plot...
绛旓細缁欎綘涓绉鐢诲垎娈靛嚱鏁鐨勬柟娉曪細浣犺繖閲屾病鏈墄=0鏃剁殑y鍊硷紝鎴戠粰浜嗛浂锛岀▼搴忎唬鐮佸涓 clc;clear;close all;i=1;for x=-20:0.1:100;if x<0 y(i)=x.^2;elseif x>0 y(i)=x+1;else y(i)=0;end i=i+1;end x=-20:0.1:100;plot(x,y,'r--');鍥惧舰锛