Create a surface from data and various vectors

1 次查看(过去 30 天)
Hello and thanks in advance,
I have the following code that I wish to improve. Specifically, I want to make the surface contours appear and have a certain opaque color. I just can't figure out how to arrange the vectors so that I can create a surf plot. Any better method is much appreciated.
{vt1=zeros(51,2);
vv=zeros(51,51);
vt=0:0.02:1;
vt1(:,1)=transpose(vt);
vt1(:,2)=vt1(:,1);
zero=zeros(51,2);
mu=tand(2/3*40);
psi=0.33;
for i=1:1:51
vv(:,i)=vt(i);
mnm(i,1)=psi*vt(i)*(1-vt(i))^(0.95);
mnm(i,2)=-1*psi*vt(i)*(1-vt(i))^(0.95);
hnm(i,1)=mu*vt(i)*(1-vt(i))^(0.95);
hnm(i,2)=-mu*vt(i)*(1-vt(i))^(0.95);
hh(:,i)=transpose(linspace(hnm(i,2),hnm(i,1),51));
mmp(:,i)=psi.*((vv(:,i).^2.*(1-vv(:,i)).^(2*0.95))-((hh(:,i)/mu).^2)).^(0.5);
mmn=-1*mmp;
end
figure(4)
plot3(vt1,mnm,zero,'b')
hold on
plot3(vt1,zero,hnm,'r')
hold on
plot3(vv,mmp,hh,'g')
hold on
plot3(vv,mmn,hh,'g')
hold on}

回答(1 个)

KSSV
KSSV 2018-1-23
vt1=zeros(51,2);
vv=zeros(51,51);
vt=0:0.02:1;
vt1(:,1)=transpose(vt);
vt1(:,2)=vt1(:,1);
zero=zeros(51,2);
mu=tand(2/3*40);
psi=0.33;
for i=1:1:51
vv(:,i)=vt(i);
mnm(i,1)=psi*vt(i)*(1-vt(i))^(0.95);
mnm(i,2)=-1*psi*vt(i)*(1-vt(i))^(0.95);
hnm(i,1)=mu*vt(i)*(1-vt(i))^(0.95);
hnm(i,2)=-mu*vt(i)*(1-vt(i))^(0.95);
hh(:,i)=transpose(linspace(hnm(i,2),hnm(i,1),51));
mmp(:,i)=psi.*((vv(:,i).^2.*(1-vv(:,i)).^(2*0.95))-((hh(:,i)/mu).^2)).^(0.5);
mmn=-1*mmp;
end
figure
hold on
% plot3(vv,mmp,hh,'g')
surf(real(vv),real(mmp),hh)
surf(real(vv),real(mmn),hh)
% plot3(vv,mmn,hh,'g')
plot3(vt1,mnm,zero,'b')
plot3(vt1,zero,hnm,'r')
shading interp
YOu need to initilaize the variables inside loop.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by