首先,确保你击中 close all force 在调用你的函数之前。 这将关闭所有打开(但可能不可见)的数字。
close all force
接下来,此片段明确告知要使用的图形和轴:
f1 = figure(); ax1 = axes(f1); p1 = plot(ax1, t,temp); f2 = figure(); ax2 = axes(f2); p2 = plot(ax2, t, Q1, t, F);
如果它仍然不起作用: 尝试传递一个 struct 含 handles 将这些数字/轴作为功能的第三个参数。在脚本中:
struct
handles
s = struct(); s.f1 = figure(); s.ax1 = axes(f1); s.f2 = figure(); s.ax2 = axes(f2); dheat(Tday,Tnight,s)
和功能:
function [s,totalheat1,totalheat2] = dheat(Tday,Tnight,s)
然后绘图部分看起来像:
p1 = plot(s.ax1, t,temp); p2 = plot(s.ax2, t, Q1, t, F);
就个人而言,我更愿意返回计算值并从脚本中调用特定于事件的事物。 p1 和 p2 可以省略。
p1
p2