|
如果硬要画,可以用如下代码:
- function huatu(a,b,c)
- clc
- t=a:0.01:b;
- y=sin(t);
- switch c
- case 1
- if isempty(get(gcf,'currentaxes'))
- hFig=plot(t,y,'r');
- else
- hOld=get(gca,'children');
- hOldFig=get(get(hOld,'parent'),'parent');
- figure;
- plot(t,y,'r');
- hNew=gca;
- copyobj(hOld,hNew)
- close(hOldFig)
- end
- case 2
- if isempty(get(gcf,'currentaxes'))
- hFig=plot(t,y,'b');
- else
- hOld=get(gca,'children');
- hOldFig=get(get(hOld,'parent'),'parent');
- figure;
- plot(t,y,'b');
- hNew=gca;
- copyobj(hOld,hNew)
- close(hOldFig)
- end
- end
复制代码
command windows中运行:
- huatu(1,2,1)
- huatu(2,3,2)
复制代码
不过恕我直言,你解决这个问题的思路实在是原始得到了家,这样的问题有save/load两个命令,把多次case中的数据加叠存储起来,一次性画,可以不涉及对句柄的复杂操作,而只是数据变量在变动,不比你这样安全和简单?! |
评分
-
1
查看全部评分
-
|