poster
2019-12-14, 20:46
我有一个脚本,可以使用stem()绘制傅立叶级数。我知道我可以用stem( , 'fill')茎末的圆。但是,我希望仅在幅度为负的情况下填充该圆,或者替换为全部填充,但在幅度为负的对象上具有另一个颜色的外部圆。
我尝试在stem()中使用变量,以及完整的if-else语句,但均返回错误。
有什么办法可以做到吗?
回答:
您可以将'Marker'属性设置为'none'从茎图中删除标记。然后使用plot或scatter功能在需要的地方添加标记。在stem命令后添加hold on并在所有绘图命令后hold off 。
例如:
x = randn(20,1); stem(x,'Marker','none') hold on plot(find(x>0),x(x>0),'ro') plot(find(x
我尝试在stem()中使用变量,以及完整的if-else语句,但均返回错误。
有什么办法可以做到吗?
回答:
您可以将'Marker'属性设置为'none'从茎图中删除标记。然后使用plot或scatter功能在需要的地方添加标记。在stem命令后添加hold on并在所有绘图命令后hold off 。
例如:
x = randn(20,1); stem(x,'Marker','none') hold on plot(find(x>0),x(x>0),'ro') plot(find(x