How to draw a line in if condition and plotting
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
My code is:
dx=0.01;
x=0:0.01:1;
dt=0.0001;
for nt=1:10001
t=(nt-1)*dt
...
if t==0
divider(:) = NaN;
end
if t>0 && t <=0.01
divider(1) = 0.25;
for i=2:ii
divider(i) = NaN;
end
end
if t>0.1 && t <=0.02
divider(1) = 0.25; divider(2) = 0.25;
for i=3:ii
divider(i) = NaN;
end
end
if t >=0.03
divider(:) = 0.25;
end
plot(x,divider,'g','Linewidth',4.4);
end
I want to see the divider in t=0, t=0.01, t=0.02,.. and it must be a horizontal line changing with time. It should be increased gradually with x axis. But it is not. How can I draw it pls?
0 件のコメント
採用された回答
Vineeth Kartha
2016 年 1 月 4 日
Hi,
In the code that you have provided above, the variable 'ii' is undefined. It is a good practice to predefine the variable 'divider', Add the line provided below before the for loop begins.
divider=zeros(1,length(x));
In the last if condition: As per the code provided I can see that the variable 'divider' has only 0.25 as the value and this will plot only a straight line 0.25. Please provide more information on the output that you are expecting. Also please post a sample image of the output that you are expecting.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!