poster
2019-12-10, 20:48
我想重用我在Matlab脚本中创建的图形。
fig1 = figure; plot(...); title(...); % ... % now I would like to plot fig1 again with a different title % ... % now I would like to plot fig1 again as a subplot in a 2x2 grid 没有代码重复怎么办?
我可以使用图形对象吗?还是以某种方式保存绘图对象?
回答:
plot和好友都在当前轴上工作,因此只需将所有代码(不包括figure )放入单独的(子)函数中,然后在设置新的Figure / title / subplot后调用它。
如果由于某种原因您无法执行此操作,请在此处查看 (http://www.mathworks.com/help/techdoc/ref/copyobj.html)页面底部的示例。
更多&回答... (https://stackoverflow.com/questions/4417819)
fig1 = figure; plot(...); title(...); % ... % now I would like to plot fig1 again with a different title % ... % now I would like to plot fig1 again as a subplot in a 2x2 grid 没有代码重复怎么办?
我可以使用图形对象吗?还是以某种方式保存绘图对象?
回答:
plot和好友都在当前轴上工作,因此只需将所有代码(不包括figure )放入单独的(子)函数中,然后在设置新的Figure / title / subplot后调用它。
如果由于某种原因您无法执行此操作,请在此处查看 (http://www.mathworks.com/help/techdoc/ref/copyobj.html)页面底部的示例。
更多&回答... (https://stackoverflow.com/questions/4417819)