From: Stargazer on 23 Jul 2010 01:19 A vector contains handles from a plot. I want to check if this vector contains a handle at a certain position how do I do this? Would this work? try figNr = input('text'); current_plot_handle = plot_handles(figNr); catch % If no handle at figNr then display error message. errmsg = lasterr; if(strfind(errmsg, 'Error using ==> getPlotHandle')) disp('This figure does not exist!') else disp('An error has occurred!') disp(errmsg) end % end if return %Return to previous function end % end try-catch How does the try-catch work? Does the function return zero values if one use 'return' How can one connect handles for a figure 4 to its plot, title .. handles?
From: Walter Roberson on 23 Jul 2010 09:30 Stargazer wrote: > A vector contains handles from a plot. I want to check if this vector contains a handle at a certain position how do I do this? ishandle()
From: Steven_Lord on 23 Jul 2010 09:31 "Stargazer" <holodeck.novelist(a)gmail.com> wrote in message news:1606824328.41068.1279876865206.JavaMail.root(a)gallium.mathforum.org... > A vector contains handles from a plot. I want to check if this vector > contains a handle at a certain position how do I do this? I'm not sure what you mean when you ask "a handle at a certain position". Do you mean you want to check if there is a graphics object with a specific handle? > Would this work? It appears to be syntactically valid. Whether it "works" depends on whether or not my guess above was correct. > try > figNr = input('text'); > current_plot_handle = plot_handles(figNr); > catch > % If no handle at figNr then display error message. > errmsg = lasterr; > if(strfind(errmsg, 'Error using ==> getPlotHandle')) Don't do this. If you must branch on the meaning of a particular error, branch based on the error identifier, not the message. In functions included with MATLAB or toolboxes, error messages change much more frequently than error identifiers. One special case of this is if you run your code on a Windows machine using the Japanese locale -- if the error message is thrown by a function created by The MathWorks it may be translated, while the error identifier will not change. > disp('This figure does not exist!') > else > disp('An error has occurred!') > disp(errmsg) > end % end if > return %Return to previous function > end % end try-catch > > How does the try-catch work? TRY/CATCH blocks are explained in the documentation for the TRY keyword: doc try > Does the function return zero values if one use 'return' Not unless that's what its function declaration line indicates it returns. The RETURN function causes a normal return to the caller function -- as though MATLAB had reached the end of the function containing the RETURN. > How can one connect handles for a figure 4 to its plot, title .. handles? I don't know what you mean by this question. If you're looking to determine what axes, plot objects, etc. are in a given figure then you can use FINDOBJ or FINDALL. If you're looking to determine in which figure an axes, plot objects, etc. are located use the ANCESTOR function. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Stargazer on 23 Jul 2010 07:36 I want to store different graphics handles for different figures. How do I do that in the best way?
From: Walter Roberson on 23 Jul 2010 11:55 Stargazer wrote: > I want to store different graphics handles for different figures. > > How do I do that in the best way? Which-ever way makes your code clearest will probably be the best way.
|
Pages: 1 Prev: constrained optimization Next: mean ,variance,standard deviation ,kurtosis of image |