Matlab:将图形绘制为函数

Matlab:将图形绘制为函数,matlab,function,graph,plot,find,Matlab,Function,Graph,Plot,Find,我正在试图找出如何将图形绘制到以下函数: 有人能帮忙吗?使用逻辑索引!有关更多信息,请参见,使用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

我正在试图找出如何将图形绘制到以下函数:

有人能帮忙吗?

使用逻辑索引!有关更多信息,请参见,使用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!
x=0:0.01:2*pi;%//或者你想要的x的任何范围
f=sin(x);%//计算sin(x)
f(f=0.7)=0.7;
绘图(x,f)%//绘制结果!

谢谢您的回复。