i want to see each plot figure for every j i have, so how can i do it?

1 回表示 (過去 30 日間)
Quynh Tran
Quynh Tran 2022 年 9 月 18 日
コメント済み: Quynh Tran 2022 年 9 月 18 日
L=5;
R=20;
i_0=0.5;
v=5;
dt1=[0.1,0.01,0.001];
for j=length(dt1)
dt=dt1(j)
t=[0:dt:1];
N=length(t);
i_bd(1)=i_0;
for k=2:N
i_bd(k)=(dt*v/L+i_bd(k-1))/(1+R/L*dt);
end
i_fd(1)=i_0;
for k=1:N-1
i_fd(k+1)=dt*v/L-i_fd(k)*(dt*R/L-1);
end
figure(j); plot(t,i_bd,t,i_fd,'LineWidth',2)
% right here I wish I could see each figure for every j, right now it only prints out plot for j=3
xlabel('Time [s]')
ylabel('Current [A]')
legend('i backward','i forward')
end

採用された回答

Simon Chan
Simon Chan 2022 年 9 月 18 日
Your for loop states j = length(dt1), which is 3 in your case. So the for loop only do figure 3 for you.
Use the following instead.
for j=1:length(dt1)

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 9 月 18 日
Instead of
figure(j)
just simply do
figure;
to bring up a totally new figure window.
  1 件のコメント
Quynh Tran
Quynh Tran 2022 年 9 月 18 日
編集済み: Quynh Tran 2022 年 9 月 18 日
it returns 1 figure (figure 1) only for j=3, figures for j=1 and j=2 are not showing. I tried hold on too but still doesn't work

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by