求解释: MATLAB Error using ==> plot Vectors must be the same lengths.set(0,'defaultaxeslinestyleorder',{'-*','-o',':s','-.d'});set(gca,'Xtick',[-10 10 130],'Xticklabel',{'-10','10

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/26 02:42:59
求解释: MATLAB Error using ==> plot Vectors must be the same lengths.set(0,'defaultaxeslinestyleorder',{'-*','-o',':s','-.d'});set(gca,'Xtick',[-10 10 130],'Xticklabel',{'-10','10
xUoDWUNw>'AcSBB|̵[RҖPiaւ4n_p&I}ޏ{^_&orS/gZ뗡%yEW0@\1ju5Xl,_QJR0M#MJ|W¥Y V cf9s vl}%S%]F}30~uFN&X?&

求解释: MATLAB Error using ==> plot Vectors must be the same lengths.set(0,'defaultaxeslinestyleorder',{'-*','-o',':s','-.d'});set(gca,'Xtick',[-10 10 130],'Xticklabel',{'-10','10
求解释: MATLAB Error using ==> plot Vectors must be the same lengths.

set(0,'defaultaxeslinestyleorder',{'-*','-o',':s','-.d'});

set(gca,'Xtick',[-10 10 130],'Xticklabel',{'-10','10','130'});

n1=300;

q=1;

b=10^(-4)/q;

E3=25/(q/b)^0.5;

A=100;

N=n1*A;

d=4;

i=0;

if d>0.5

 for d=4:-0.1:0.5

    i=i+1;

    f=@(z)(z-d).^(3/2).*1/sqrt(2*pi).*exp(-z.^2/2);

    Q(i)=quad(f,d,40);

    P1(i)=Q(i)*4/3*N*E3*sqrt(b);

    plot(P1,4:-0.1:0.5,'g')

 end

end

hold on

 if d<=0.5

    for d=0.4:-0.1:0

    i=i+1;

    f=@(z)(z-d).^(3/2).*1/sqrt(2*pi).*exp(-z.^2/2)+3;

    Q(i)=quad(f,d,40);

    P2(i)=Q(i)*4/3*N*E3*sqrt(b); 

    plot(P2,0.4:-0.1:0,'g')

    end

 end


相当于分段函数


结果如下,为什么? 


求解释: MATLAB Error using ==> plot Vectors must be the same lengths.set(0,'defaultaxeslinestyleorder',{'-*','-o',':s','-.d'});set(gca,'Xtick',[-10 10 130],'Xticklabel',{'-10','10
把plot从for循环里面拿出来,放到循环的后面,你现在每次for循环都会做一次plot,但在你的for循环结束之前,你的P1和P2根本都还没全部赋值完毕