plot in same graph from a loop

1 回表示 (過去 30 日間)
samuel herrera
samuel herrera 2021 年 11 月 17 日
回答済み: Prateek Rai 2021 年 11 月 21 日
G = 10*10-9;% conductividad
l = 1*10^-3;
c = 10*10^-9;
u = 4*pi*10^-7;
e = (l*c)/u;
g = (u*G)/l;
vs = 1;
f = [60 1000];
zs = 50;
long = 100;
x = 0:0.1:100;
%condicione de la carga
zl = -1.2839j;
for ii=1:length(f)
w(ii) = 2*pi*f(ii);
z0(ii) = ((1j*w(ii)*l)/(g+1j*w(ii)*c))^(1/2);
prop(ii) = (1j*w(ii)*l*(g+1j*w(ii)*c))^(1/2);
A{ii} = [(z0(ii)+zs),(z0(ii)-zs);(z0(ii)-zl)*exp(-prop(ii)*long),(z0(ii)+zl)*exp(prop(ii)*long)];
ainv{ii} = inv(A{ii});
vo{ii} = ainv{ii}*[z0(ii)*vs;0];
vp1{ii} = vo{ii}(1);
vp2{ii} = vo{ii}(2);
end
vp=cell2mat(vp1);
vn=cell2mat(vp2);
for r=1:length(vp)
vt(ii)=abs(vp(ii)*exp(-prop*x)+vn(ii)*exp(prop*x));
plot(x,vt(ii))
end
how can i plot the answears for vt(ii) in the same plot? thanks a lot

回答 (1 件)

Prateek Rai
Prateek Rai 2021 年 11 月 21 日
Hi,
You can try "hold on" to retain current plot when adding new plot.
Refer to hold MathWorks documentation page to learn more on retaining current plot when adding new plot.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by