Reputation: 66
I am trying to figuring out how to plot graph to the following function:
Anyone that can help?
Upvotes: 0
Views: 292
Reputation: 8459
Use logical indexing! See this link for more information, logical indexing is a very useful thing to be familiar with when using Matlab!
x=0:0.01:2*pi; %// or whatever range of x you want
f=sin(x); %// calculate sin(x)
f(f<=0.5)=0.5; %// make the values of sin(x) less than or equal to 0.5 equal to 0.5
f(f>=0.7)=0.7;
plot(x,f) %// plot the result!
Upvotes: 2