查看单个帖子
旧 2019-12-10, 20:48   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,008
声望力: 66
poster 正向着好的方向发展
帖子 如何在Matlab中重用图形?

我想重用我在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后调用它。

如果由于某种原因您无法执行此操作,请在此处查看页面底部的示例。



更多&回答...
poster 当前离线   回复时引用此帖