matlab中for循环画三维曲面图 5
利用两个for循环的变量作为横纵坐标画三维曲面图。目前只能画出polt3图。求大神指点。或者不使用for循环达到同样的效果。clear;clcO2=[5,5,5,5,5]...
利用两个for循环的变量作为横纵坐标 画三维曲面图。
目前只能画出polt3图。求大神指点。
或者不使用for循环 达到同样的效果。
clear;clcO2=[5,5,5,5,5];
P=[1,5,8,10,12];
NO=[180,194,213,213,213];
T=[15,75,120,150,180];
Y0=[0.027777778,0.584536082,0.741314554,0.797652582,0.856338028];
F1=10
for k1=0.001:0.01:1
for K1=0.001:0.01:0.2
for i=1:length(P)
a(i)=k1*O2(i)*P(i)*K1;
b(i)=2*K1*NO(i)*P(i)/10000;
c(i)=-K1*[(NO(i)*P(i)/10000).*(NO(i)*P(i)/10000)];
c0(i)=-1/(sqrt(b(i)^2-4*a(i)*c(i)))*log((2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i))));
X(i)=(2*sqrt(b(i)^2-4*a(i)*c(i))/(-exp(-(c0(i)+T(i))*sqrt(b(i)^2-4*a(i)*c(i)))+1)-sqrt(b(i)^2-4*a(i)*c(i))-b(i))/(2*a(i)*P(i)/10000);
M(i)=(2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i)));
if M(i)<0
c0(i)=-1/(sqrt(b(i)^2-4*a(i)*c(i)))*log(-(2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i))));
X(i)=(2*sqrt(b(i)^2-4*a(i)*c(i))/(exp(-(c0(i)+T(i))*sqrt(b(i)^2-4*a(i)*c(i)))+1)-sqrt(b(i)^2-4*a(i)*c(i))-b(i))/(2*a(i)*P(i)/10000);
end
end
for j=1:length(a)
f(j)=((1-X(j)/NO(j))-Y0(j))^2;
end
F=sum(f,2)
plot3(k1,K1,F,'r.','markersize',2)
grid on;hold on;
if F<F1
F1=F
A=k1
B=K1
end
end
end 展开
目前只能画出polt3图。求大神指点。
或者不使用for循环 达到同样的效果。
clear;clcO2=[5,5,5,5,5];
P=[1,5,8,10,12];
NO=[180,194,213,213,213];
T=[15,75,120,150,180];
Y0=[0.027777778,0.584536082,0.741314554,0.797652582,0.856338028];
F1=10
for k1=0.001:0.01:1
for K1=0.001:0.01:0.2
for i=1:length(P)
a(i)=k1*O2(i)*P(i)*K1;
b(i)=2*K1*NO(i)*P(i)/10000;
c(i)=-K1*[(NO(i)*P(i)/10000).*(NO(i)*P(i)/10000)];
c0(i)=-1/(sqrt(b(i)^2-4*a(i)*c(i)))*log((2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i))));
X(i)=(2*sqrt(b(i)^2-4*a(i)*c(i))/(-exp(-(c0(i)+T(i))*sqrt(b(i)^2-4*a(i)*c(i)))+1)-sqrt(b(i)^2-4*a(i)*c(i))-b(i))/(2*a(i)*P(i)/10000);
M(i)=(2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i)));
if M(i)<0
c0(i)=-1/(sqrt(b(i)^2-4*a(i)*c(i)))*log(-(2*a(i)*NO(i)*P(i)/10000+b(i)-sqrt(b(i)^2-4*a(i)*c(i)))/(2*a(i)*NO(i)*P(i)/10000+b(i)+sqrt(b(i)^2-4*a(i)*c(i))));
X(i)=(2*sqrt(b(i)^2-4*a(i)*c(i))/(exp(-(c0(i)+T(i))*sqrt(b(i)^2-4*a(i)*c(i)))+1)-sqrt(b(i)^2-4*a(i)*c(i))-b(i))/(2*a(i)*P(i)/10000);
end
end
for j=1:length(a)
f(j)=((1-X(j)/NO(j))-Y0(j))^2;
end
F=sum(f,2)
plot3(k1,K1,F,'r.','markersize',2)
grid on;hold on;
if F<F1
F1=F
A=k1
B=K1
end
end
end 展开
1个回答
2017-09-29
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询