Hi guys, I need a lil help,please

1 回表示 (過去 30 日間)
ORION OMN
ORION OMN 2019 年 3 月 27 日
コメント済み: Star Strider 2019 年 3 月 27 日
I am writing a piece of code using for loop and if -elseif statments to get 4 different curves with different parameters all plotting on the same graph but it seems that matlab doesn't see the different parameters values. I only got 4 curves on each other with no change.
figure
xlim([-40 100])
ylim ([0 100])
for ii=1:4;
if ii == 1
theta=30;
FOV=50;
color = 'k';
style = '-';
hold on
elseif ii == 2
theta=40;
FOV=40;
color = 'r';
style = '-.';
hold on
elseif ii == 3
theta=50;
FOV=30;
color = 'm';
style = '--';
hold on
elseif ii == 4
theta=60;
FOV=20;
color = 'b';
style = ':';
end
set(gca,'XTick',[0 20]);
set(gca,'YTICK',[0 20 40]);
plot(x ,SNR_db,'Color',color,'LineStyle',style );
lgd = legend( 'thetad 30,FOVd 50','thetad 40,FOVd 40','thetad 50,FOVd 30','thetad 60,FOVd 20');
end
hold off
xlabel('x[m]')
ylabel('SNR[dB]')
title('SNR distrbution at first lane')
I think I did something wrong but I don't know where.

採用された回答

Catalytic
Catalytic 2019 年 3 月 27 日
編集済み: Catalytic 2019 年 3 月 27 日
Your loop is sending the same x and SNR_dB to the plot command in every iteration. The data you are plotting does not vary through the loop at all.
  5 件のコメント
ORION OMN
ORION OMN 2019 年 3 月 27 日
Thanks for your replying, I got what you mean and I will give it a try.
Star Strider
Star Strider 2019 年 3 月 27 日
My pleasure.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by