Matlab function that accepts figure handle or file name as input?
Afficher commentaires plus anciens
I want to write a matlab function that except one input argument, it can be a figure handle or file name to .fig file. If no input is provided I will invoke uigetfile. So far I can not get my function accept figure handle and modify the plot. Remember code should also check if the input is figure-handle or file name. Please help me with this.
function []=changexlim(varargin)
% This function changes xlim for various values and
narginchk(0,1)
if nargin==0
[file,path]=(uigetfile('*.fig','Select matlab figure'));
fil=fullfile(path,file);
openfig(fil)
xlim([0 5])
end
if nargin==1
check=ishandle(varargin)
if check==1
gca=get(varargin,'CurrentAxis')
xlim(gca,[0 5])
else if check==0
openfig(varargin)
xlim([0 5])
end
end
figure(varargin)
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!