Search Comments and Ratings

go

   
Date File Comment by Comment Rating
27 Jan 2015 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Ken Purchase

Revised, with many thanks to the Matlab User
Community, including Matt J, Hoi Wong, Philip Caplan.

Comment only
10 Dec 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Hoi Wong

Hoi Wong (view profile)

TMW's support really go the extra mile helping its customers. With the help of Philip Caplan, the last bit of the puzzle to get this to work on R2014b's new graphic system is solved.

Replace:
hgp = findpackage('hg');
axesC = findclass(hgp,'axes');
LimListener = handle.listener(imAxes,[axesC.findprop('XLim') axesC.findprop('YLim')],...
'PropertyPostSet',@localLimitListener);

With:
LimListener = addlistener(imAxes,{'XLim','YLim'},'PostSet',@localLimitListener);

Comment only
19 Nov 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Matt J

Matt J (view profile)

@David,
I believe the particular error you mention is fixable by changing that line as follows

PostPositionListener = addlistener(hFig,'SizeChanged',...
@(o,e) localPostPositionListener(o,e,imAxes) );

See also the following thread in MATLAB Answers,

<http://www.mathworks.com/matlabcentral/answers/163280-addlistener-syntax-not-recognized-in-r2014b>

However, I'm afraid that even after fixing that, I am finding further problems running TextZoomable in R2014b. In particular, the following lines use undocumented functions findpackage and findclass,

hgp = findpackage('hg');
axesC = findclass(hgp,'axes');

whose behavior has changed somehow.

Comment only
17 Nov 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase David

David (view profile)

I'm trying to use your code with R2014b and I get this error:
No method 'addlistener' with matching signature found for class 'matlab.ui.Figure'.

I've run the script provided by Mathworks to update code for the new graphics system and it changed one line, but it still doesn't work. Any ideas?

Comment only
27 Mar 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Matt J

Matt J (view profile)

Here's a better version of the DeleteFcn,

function DeleteMethod(src,event)
% when called, rescale all fonts in image
hAx=gca;
hFig = get(hAx,'Parent');
ud=get(hAx, 'UserData');
idx=(ud.handles==src);

ud.ratios(idx)=[];
ud.handles(idx)=[];



if isempty(ud.handles)
setappdata(hFig,'KenAxeResizeListeners',[]);
set(hAx, 'UserData',[]);
else
set(hAx, 'UserData',ud);
end

delete(src);

end

Comment only
27 Mar 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Matt J

Matt J (view profile)

Ken,

There seems to be a duplicate of this submission at

http://www.mathworks.com/matlabcentral/fileexchange/41501-textzoomable-for-text-that-scales-as-you-zoom

Which is the most official/current version? Also, when I do a very high zoom on the text, parts of the text appear outside the axes. Is there a way to prevent this, i.e., so that only text within the window of the axes is visible?

Comment only
27 Mar 2014 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Matt J

Matt J (view profile)

I get the same errors/warnings as Nispio, but setting txtHandle's DeleteFcn callback to the following seems to fix it.

function DeleteMethod(src,event)
% when called, rescale all fonts in image
hAxes=gca;
hFig = get(hAxes,'Parent');
setappdata(hFig,'KenAxeResizeListeners',[]);
set(hAxes, 'UserData',[]);
delete(src);
end

4
04 Nov 2013 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Nispio

Nispio (view profile)

This gives the following warnings/errors whenever I try to plot over the top of my old plot.

Warning: Error occurred while evaluating listener callback.
> In axis>LocSetTight1 at 332
In axis>LocSetTight at 277
In axis>LocSetImage at 414
In axis at 135
In showimage at 5
Attempt to reference field of non-structure array.

Error in TextZoomable>getBestFontSize (line 70)
fs = round(ud.ratios * hFigFactor / axHeight);

Error in TextZoomable>localLimitListener (line 106)
fs = getBestFontSize(imAxes);

4
04 Nov 2013 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Nispio

Nispio (view profile)

5
18 Oct 2013 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Krishnakumar

5
07 Jun 2013 TextZoomable for text that scales as you zoom Text that zooms as you zoom your plot, rather than staying at a fixed font size. Author: Ken Purchase Simon

Simon (view profile)

5
20 Jun 2011 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase Sina Tootoonian

@Andy:

I got the same problem. The cause seemed to be that intrafun passes varargin to the function to m inimize, and if the latter function can't handle it, an error is generated.

The workaround I found was to let my function accept varargin as a dummy argument e.g. If my function was f = @(x) x^2, to change it to f = @(x,varargin) x^2. When this is done, the new function can handle the varargin passed in through intrafun, and no error results.

Hope this helps!

Comment only
30 Nov 2009 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase Andrew

Andrew (view profile)

Has anybody been able to run this function in a parfor loop?

Comment only
22 May 2009 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase Chris Men

good job and thank you very much

5
29 Mar 2009 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase Andy

Andy (view profile)

I was going to use this code to fit Gaussians to a known curve by minimizing the known - fit residual. I tried for 3 and 4 Gaussians, meaning 9 or 12 variables. This newer code fails giving the error:

Too many input arguments.

Error in ==> fminsearchbnd>@(x,varargin)fun(xtransform(x),varargin{:}) at 233
intrafun = @(x, varargin) fun(xtransform(x), varargin{:});

Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});

Error in ==> fminsearchbnd at 264
[xu,fval,exitflag,output] = fminsearch(intrafun,x0u,options,varargin);

The original code by John D'Errico works perfectly.

Comment only
04 Dec 2007 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase John D'Errico

I like the changes that Ken has made. They clean up the code nicely. Not much to say other than - well done.

5
30 Nov 2007 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase Ken Purchase

Thanks John - I realize I shipped it with a few bugs. I'll update it when I get to the office Monday.

Comment only
30 Nov 2007 fminsearchbnd new improved bounded fminsearch algorithm Author: Ken Purchase John D'Errico

I'll get to a careful review of this asap, but until I do, I'll note that the optimization toolbox is listed as a requirement. Since fminsearch is part of Matlab, that toolbox should not be necessary. Until then, it looks like Ken has found some things to clean up in my code. If so, well done.

Comment only

Contact us