2
我已經在MATLAB中編程創建了一個GUI,它允許用戶調整某些參數以更改軸上顯示的數據。我希望用戶能夠將這些軸保存爲MATLAB圖。我嘗試了通過谷歌和MATLAB文檔發現的多種方法,但都沒有奏效。MATLAB:如何將GUI中生成的座標軸保存爲'.fig'文件?
我現在不工作代碼:
% Creation of the axes ui component
a1 = axes('Units','pixels','Position',[20,18,270,255],'box','on');
% Skipped ahead to callback for 'save' menu item
function menu1_callback(~,~)
% Creates a new figure
f2 = figure;
% Copies the axes a1 to the new figure
copyobj(a1,f2);
% Save the new figure
saveas(gcf,'filename','fig');
end
這是MATLAB產生錯誤:
Error using getProxyValueFromHandle (line 15)
Input must be a valid handle.
Error in plotedit (line 91)
[varargout{1:nargout}] = feval(args{:});
Error in specgraph.barseries/preserialize (line 10)
peerVals = plotedit({'getProxyValueFromHandle',hPeers});
Error in hgsaveStructDbl (line 80)
olddata{i} = {hh,preserialize(hh)};
Error in hgsave (line 62)
hgS = hgsaveStructDbl(h, SaveAll);
Error in saveasfig (line 7)
hgsave(h, name);
Error in saveas (line 126)
feval(['saveas' format], h, name)
Error in GBdataVisualiser2/menu1_callback (line 165)
saveas(gcf,'filename','fig');
Error while evaluating uimenu Callback
恐怕產生僅由在代碼的變化不同的幾乎相同的錯誤: '錯誤GBdataVisualiser2/menu1_callback(線165) 另存爲(F2, '文件名', '無花果'); ' – phototronic