Where do I have to put the plot?

1 回表示 (過去 30 日間)
Lorena Ortiz
Lorena Ortiz 2015 年 5 月 4 日
コメント済み: Lorena Ortiz 2015 年 5 月 4 日
I want to plot Vcr as a function of m. In the solution of the program it is obtained that Vcr is
Vcr= 0 1 2 3 4
so something should appear, but I get this (nothing):
I don't know where and how I have to put the function plot in the code to obtain what I want. Here is the code:
close all
s=input('Introduce s(1-40): ');
n=input('Introduce n (1-100): ');
t=1000;
mf=zeros(1,s);
Vf=zeros(s,n);
cf=zeros(s,n,t);
Vcr=zeros(1,s);
Ccr=zeros(1,s);
syms c V m;
F=-m+V+c+i*(m-V-c);
Re=real(F)
Im=imag(F)
for h=1:s
mf(h)=h;
m=mf(h);
for j=1:n
Vf(h,j)=j;
V=Vf(h,j);
PRe=subs(Re) ;
d=0.01 ; %step size
D=20;
Nvec=[1:d:D];
step=length(Nvec);
for g=1:step
cf(h,j,g)=g;
c=cf(h,j,g);
Prec=subs(PRe);
if Prec>-0.0001 && Prec<0.0001
cr=c;
break
else
cf(h,j,g)=cf(h,j,g);
end
end
PImag=subs(Im)
if PImag==-1900
Vcr(1,h)=V;
Ccr(1,h)=c;
else
Vf(h,j)=Vf(h,j);
end
end
end
disp ('Las velocidades de migración son: ')
Ccr
disp('las velocidades criticas son: ' )
Vcr
plot(m,Vcr)
Thank you for your help!

採用された回答

Purushottama Rao
Purushottama Rao 2015 年 5 月 4 日
IN your m-file, m results in a scalar value. Whereas Vcr is an array.
Replace the plot command with plot(1:m,Vcr) or plot(0:m-1,Vcr)
  1 件のコメント
Lorena Ortiz
Lorena Ortiz 2015 年 5 月 4 日
Thank you Purushottama Rao for your help! Now I get the result that I wanted.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by