plot intermediate value in a for statement

1 回表示 (過去 30 日間)
vincenzo violi
vincenzo violi 2021 年 1 月 9 日
回答済み: vincenzo violi 2021 年 1 月 10 日
Hello,
I have a for statement , with n= 1:1024.
I would like to plot intermediate value result at 64, and 256. instead of doing 3 for statement (1:64, 1:256, 1:1024),
how Can I plot 3 curves with a single for?
I write my code to let you understand better.
n=[1:1024];
d1range=10:100
for k = 1:length(d1range)
.
.
.
.
for j = 1:length(n)
LRIS(k)=LRIS(k)+((sqrt((1/(Lsrpw02(k)*Lrdpw08(k))))));
%conversione in DB
end
LRIS2(k)=LRIS(k)^(-2);
LRISDB(k)=pow2db( LRIS2(k));
end
hold on; box on;
plot(d1range,LRISDB(:,1),'b-o','LineWidth',1);
  11 件のコメント
Walter Roberson
Walter Roberson 2021 年 1 月 10 日
LRIS(k) = LRIS(k) + 1 / sqrt(Lsrpw02(k) * Lrdpw08(k));
if ismember(k, [64 256 1024])
do whatever plotting is appropriate
hold on
end
Walter Roberson
Walter Roberson 2021 年 1 月 10 日
If j=64 && j==256 && 1024
To use that form of code you would instead need
if j == 64 || j == 256 || j == 1024

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

回答 (1 件)

vincenzo violi
vincenzo violi 2021 年 1 月 10 日
thank you all for your help, you have been really kind! :)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by