필터 지우기
필터 지우기

How to draw a line in if condition and plotting

조회 수: 1 (최근 30일)
Meva
Meva 2015년 12월 29일
댓글: Meva 2016년 1월 4일
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?

채택된 답변

Vineeth Kartha
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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by