【问题标题】:Subplot using hold and elseif in matlab在matlab中使用hold和elseif的子图
【发布时间】:2013-06-24 21:16:55
【问题描述】:

我在绘制图形时遇到问题。 无法在我的 GUI 中的对象(轴)中绘制旧图形。

代码:

if get(handles.checkerro,'Value') == 1
    plot(handles.axes4,tempo,real(Erro)','r')
    hold on
elseif get(handles.checkcalc,'Value') == 1
    plot(handles.axes4,tempo,real(Signal)')
    hold on
elseif get(handles.checksignal,'Value') == 1
    plot(handles.axes4,tempo,data)
end

checkerro、checkcalc 和 checksignal 是 ckeckboxes(GUI 对象)

Erro、Signal 和 tempo 是大小相同的矩阵。

当我选择了 ckeckerro 和 checkcalc(示例)时,只能看到绘制的速度与真实(错误)。

我在等待帮助。

谢谢

【问题讨论】:

  • 您是想用新的图表替换之前的图表,还是将其添加到图表中?

标签: matlab matlab-guide subplot


【解决方案1】:

流控制语句if ... elseif ... 的类型为exclusive or。在伪代码中意味着:

if A is true
    then A
otherwise if B is true
    then only B
end

你可能只是想要:

if get(handles.checkerro,'Value') == 1
    plot(handles.axes4,tempo,real(Erro)','r')
    hold on
end

if get(handles.checkcalc,'Value') == 1
    plot(handles.axes4,tempo,real(Signal)')
    hold on
end

if get(handles.checksignal,'Value') == 1
    plot(handles.axes4,tempo,data)
end

【讨论】:

    猜你喜欢
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 2018-10-27
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    • 1970-01-01
    相关资源
    最近更新 更多