3 Matlab questions
1 – Does anyone know if there is an equivalent to
#pragma GCC poison variable_name
in matlab, i.e. it causes matlab to error if it finds variable_name being used from this point onwards in the code?
Two other less related questions, as i still can’t believe it.
2 – Is there anyway to link commands like
imagesc(I1_avg_crop, [bg_value multiplier2*std_value+bg_value]);
to a figure in particular, other than doing
set(0,'CurrentFigure',fig3);
imagesc(I1_avg_crop, [bg_value multiplier2*std_value+bg_value]);
immediately before it?
3 – can getframe() (or similar) actually get whats in a figure rather than “doing a screen capture”?, as it doesn’t work so well when the figure window is moved?
(I’m editing someones code, and i am new to matlab, so i apologise in advance if these are stupid questions, its just i can’t locate what i want in the documentation)
EDIT: Extra Question
The manual says
set(0,'CurrentFigure',h);
Makes the figure h current, but do not change its visibility or stacking with respect to other figures. Does this still apply on Mac OS X as it seems to still force it to the top?
(1) No, it isn’t possible to “natively” poison a variable. However, you can do the following workaround: Define a class like this:
Then you can call
variable_name = poison('variable_name')and get the same effect – ifvariable_nameis overwritten, it triggers the object’s delete method and throws an error, if there is an attempt at indexing, or at arithmetic manipulation, there are generic errors.(2) You can set the parent of the image explicitly (pass an axes handle, which you can e.g. obtain by
axHandle = axes('Parent',fig3);) in the function call, which avoids calling the figure. However, you cannot do that and set colormap scaling. Thus, you have to either useor, if you don’t have acces to the image processing toolbox, you need to use
image(3) If you call
getframewith an axes handle, it should be able to capture the contents of the axes – unless you moved the figure onto the second screen, in which case it won’t work. BTW: I have noticedgetframeto have issues on OSX in the past, e.g. with docked figures.(4) There are, at times OSX-specific issues with Matlab, as they are still debugging some of the very basic stuff (the OSX version used to be the Linux version running in X-Windows, and they’ve been working on changing that for the last few years).