Figure 's issue

조회 수: 1 (최근 30일)
M
M 2022년 9월 12일
편집: Torsten 2022년 9월 13일
Hi everyone. I wrote the code below for plotting a 2d figure (ct-h) but it doesn't work; I mean it doesn't show any figure. Could you please tell me what is the problem, and how can I solve it?
Thanks in advance for any help.
vplc=0.16;
delta=0.1;
Ktau=0.045;
Kc=0.1;
K=0.0075;
Kp=0.15;
gamma=5.5;
kb=0.4;
vss=0.044;
alpha0=delta*6.81e-6/(0.002);
alpha1=delta*2.27e-5/(0.002);
Ke=7;
Vs=0.002;
ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
[ct]=meshgrid(0.0001:0.05:30);
x=(((2.*Vs.*K.*gamma.^2.*ct.^2)./(vss))+((2.*alpha0.*ks.^2)./(vss))+((2.*Ke.^4.*ks.^2.*alpha1)./(vss.*(Ke.^4+(gamma.*ct).^4))));
p=(vplc./ki).*(x./((kplc).^2+x));
A=(-(vss.*x)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=-(0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*x.^2.*gamma.*ct.*Kf)));
plot(ct,h);

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 12일
편집: Walter Roberson 2022년 9월 12일
[ct]=meshgrid(0.0001:0.05:30);
is treated the same way as if you had used
[ct, ~]=meshgrid(0.0001:0.05:30, 0.0001:0.05:30);
It creates a 600 x 600 grid that is just a lot of repeats of the same values. So you end up plotting 600 lines.
I suggest you use semilogy instead of plot()
  댓글 수: 6
Torsten
Torsten 2022년 9월 12일
편집: Torsten 2022년 9월 13일
With "plot(ct,h)" also worked and gave me the figure that I expected
I only see one small jump at 0 and everything else on the zero level
vplc=0.16;
delta=0.1;
Ktau=0.045;
Kc=0.1;
K=0.0075;
Kp=0.15;
gamma=5.5;
kb=0.4;
vss=0.044;
alpha0=delta*6.81e-6/(0.002);
alpha1=delta*2.27e-5/(0.002);
Ke=7;
Vs=0.002;
ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
ct=0.0001:0.05:2;
x=(((2.*Vs.*K.*gamma.^2.*ct.^2)./(vss))+((2.*alpha0.*ks.^2)./(vss))+((2.*Ke.^4.*ks.^2.*alpha1)./(vss.*(Ke.^4+(gamma.*ct).^4))));
p=(vplc./ki).*(x./((kplc).^2+x));
A=(-(vss.*x)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=-(0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*x.^2.*gamma.*ct.*Kf)));
plot(ct,h);
whereas the semilogy option gives a good resolution of the different scales:
vplc=0.16;
delta=0.1;
Ktau=0.045;
Kc=0.1;
K=0.0075;
Kp=0.15;
gamma=5.5;
kb=0.4;
vss=0.044;
alpha0=delta*6.81e-6/(0.002);
alpha1=delta*2.27e-5/(0.002);
Ke=7;
Vs=0.002;
ks=0.1;
Kf=0.18;
kplc=0.055;
ki=2;
ct=0.0001:0.05:2;
x=(((2.*Vs.*K.*gamma.^2.*ct.^2)./(vss))+((2.*alpha0.*ks.^2)./(vss))+((2.*Ke.^4.*ks.^2.*alpha1)./(vss.*(Ke.^4+(gamma.*ct).^4))));
p=(vplc./ki).*(x./((kplc).^2+x));
A=(-(vss.*x)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=-(0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*x.^2.*gamma.*ct.*Kf)));
semilogy(ct,h);
M
M 2022년 9월 12일
Yeah, that's true, and I understood what you said, but the point is that only this part ct=[0,2] and h=[0,1] is important for me, and with "plot", it seems to work better (at least for this case).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by