求解释: 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/07/02 16:59:12
![求解释: 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](/uploads/image/z/11508671-47-1.jpg?t=%E6%B1%82%E8%A7%A3%E9%87%8A%3A+MATLAB+Error+using+%3D%3D%3E+plot+Vectors+must+be+the+same+lengths.set%280%2C%26%2339%3Bdefaultaxeslinestyleorder%26%2339%3B%2C%7B%26%2339%3B-%2A%26%2339%3B%2C%26%2339%3B-o%26%2339%3B%2C%26%2339%3B%3As%26%2339%3B%2C%26%2339%3B-.d%26%2339%3B%7D%29%3Bset%28gca%2C%26%2339%3BXtick%26%2339%3B%2C%5B-10+10+130%5D%2C%26%2339%3BXticklabel%26%2339%3B%2C%7B%26%2339%3B-10%26%2339%3B%2C%26%2339%3B10)
求解释: 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根本都还没全部赋值完毕