Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6046953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:17:54+00:00 2026-05-23T07:17:54+00:00

3 Matlab questions 1 – Does anyone know if there is an equivalent to

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:17:54+00:00Added an answer on May 23, 2026 at 7:17 am

    (1) No, it isn’t possible to “natively” poison a variable. However, you can do the following workaround: Define a class like this:

    classdef poison 
       properties (SetAccess=private)
          varName
       end
       methods
         function obj = poison(varName)
            obj.varName = varName;
         end
         function delete(obj)
            error('attempting to overwrite ''%s''',obj.varName)
         end
       end
    end
    

    Then you can call variable_name = poison('variable_name') and get the same effect – if variable_name is 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 use

    imshow(I1_avg_crop,[bg_value multiplier2*std_value+bg_value],'Parent',axHandle);
    

    or, if you don’t have acces to the image processing toolbox, you need to use image

    image(I1_avg_crop, 'CDataMapping','scaled','Parent',axHandle);
    set(axHandle,'clim',[bg_value multiplier2*std_value+bg_value])
    

    (3) If you call getframe with 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 noticed getframe to 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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting some MATLAB functions to Scilab . The cool thing is that there
My knowledge of matlab is merely on a need to know basis, so this
Is there an open-source alternative to MATLAB's fmincon function for constrained linear optimization? I'm
I have some questions regarding the MATLAB Search Path: The current directory is on
I like to debug in matlab using commands. some questions: If choose a stack,
Given my previous questions about the the usage of AMPL. Are there any other
I have noticed that matlab does some matrix function really fast for example adding
There are a lot of questions about matplotlib, pylab, pyplot, ipython, so I'm sorry
I got this weird error when I was trying to compile matlab to C++
My question is Matlab related. There exist a fnct named nchoosek([vector],integer). By using this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.