简化MATLAB程式clc; clear ;k=1;C=0.5;C1=1;C2=2;for h=-5:0.01:5x(k)=h;y1(k)=sqrt(C-(h.^2/(1+h.^2)));y2(k)=-sqrt(C-(h.^2/(1+h.^2)));y3(k)=sqrt(C1-(h.^2/(1+h.^2)));y4(k)=-sqrt(C1-(h.^2/(1+h.^2)));y5(k)=sqrt(C2-(h.^2/(1+h.^2)));y6(k)=-sqrt(C2-(h.^2/(1

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 14:30:31
简化MATLAB程式clc;clear;k=1;C=0.5;C1=1;C2=2;forh=-5:0.01:5x(k)=h;y1(k)=sqrt(C-(h.^2/(1+h.^2)));y2(k)=-sq

简化MATLAB程式clc; clear ;k=1;C=0.5;C1=1;C2=2;for h=-5:0.01:5x(k)=h;y1(k)=sqrt(C-(h.^2/(1+h.^2)));y2(k)=-sqrt(C-(h.^2/(1+h.^2)));y3(k)=sqrt(C1-(h.^2/(1+h.^2)));y4(k)=-sqrt(C1-(h.^2/(1+h.^2)));y5(k)=sqrt(C2-(h.^2/(1+h.^2)));y6(k)=-sqrt(C2-(h.^2/(1
简化MATLAB程式
clc; clear ;
k=1;C=0.5;C1=1;C2=2;
for h=-5:0.01:5
x(k)=h;
y1(k)=sqrt(C-(h.^2/(1+h.^2)));
y2(k)=-sqrt(C-(h.^2/(1+h.^2)));
y3(k)=sqrt(C1-(h.^2/(1+h.^2)));
y4(k)=-sqrt(C1-(h.^2/(1+h.^2)));
y5(k)=sqrt(C2-(h.^2/(1+h.^2)));
y6(k)=-sqrt(C2-(h.^2/(1+h.^2)));
k=k+1;
end
plot(x,y1,x,y2,x,y3,x,y4,x,y5,x,y6)
可以请各位前辈们帮忙简化下程式吗?

简化MATLAB程式clc; clear ;k=1;C=0.5;C1=1;C2=2;for h=-5:0.01:5x(k)=h;y1(k)=sqrt(C-(h.^2/(1+h.^2)));y2(k)=-sqrt(C-(h.^2/(1+h.^2)));y3(k)=sqrt(C1-(h.^2/(1+h.^2)));y4(k)=-sqrt(C1-(h.^2/(1+h.^2)));y5(k)=sqrt(C2-(h.^2/(1+h.^2)));y6(k)=-sqrt(C2-(h.^2/(1
% C = ...
h=-5:0.01:5;
y1=sqrt(C-(h.^2./(1+h.^2)));
y2=-sqrt(C-(h.^2./(1+h.^2)));
y3=sqrt(C1-(h.^2./(1+h.^2)));
y4=-sqrt(C1-(h.^2./(1+h.^2)));
y5=sqrt(C2-(h.^2./(1+h.^2)));
y6=-sqrt(C2-(h.^2./(1+h.^2)));
% plot...
这样就是向量化操作了.