I would like to plot a straight line over a interval. For example, I have two variables: h and Time. When Time is between 0 to 0.56, the h value is 0.25. I need it to be a straight line. Similarly, for other points.When i use the function plot(Time,h), the lines are connected. I don't want this.
Need some guidance on this..
It looks like this:
What I have tried so far?
function PlotH(Time,h)
for i=2:size(Time)
x = h(i)*ones(1,Time(i));
hold on;
end
plot(x)
ymax = max(h);
xlim([1 max(Time)]);
ylim([-0.5 ymax+0.5]);
xlabel('Time')
ylabel('Rate')
end
plot(Time,h,L)
. And setL=
, based on what you want.L = '-'
line,L = '.'
points,L = '--'
dashed line,L = 'o'
empty points. Also, ever tried pressing F1 while hovering over a function in Matlab? quite helpful – The-Duck'.'
. Try usingplot(Time(1:5,h(1:5),'-');hold on;plot(Time(6:end),h(6:end),'.')
– The-Duck