Create a surface from data and various vectors

조회 수: 4 (최근 30일)
ClaudioP
ClaudioP 2018년 1월 23일
댓글: ClaudioP 2018년 1월 23일
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