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

  • Home
  • SEARCH
  • 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 8608243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:33:32+00:00 2026-06-12T03:33:32+00:00

Save this sample function as test_func.m : function test_func load test.mat whos alpha and

  • 0

Save this sample function as test_func.m:

function test_func
load test.mat
whos
alpha

and run this sample script:

alpha = 3;
save test.mat
test_func

Here is the output I get:

  Name       Size            Bytes  Class     Attributes

  alpha      1x1                 8  double              

??? Error using ==> alpha at 40
Not enough input arguments.

Error in ==> test_func at 4
alpha

The output of whos shows that the variable is loaded in the local workspace of the function. I can even put a breakpoint on line 4 of test_func and type alpha and I get the correct result, but as soon as I do a step forward with the debugger, it fails again: the function alpha is masking the local variable and I don’t see why.

Replacing the content of test_func by

p = load('test.mat');
p.alpha

works fine but that’s not what I’m trying to do. I would like to load variables directly inside the local workspace of the function.

To me it looks like a bug (I’m using Matlab R2011a) but if it’s a feature can you explain it and help me find a workaround?

  • 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-06-12T03:33:34+00:00Added an answer on June 12, 2026 at 3:33 am

    Heh, you might be right that this is a bug. Looks really strange, because the following works

    function test_func
    load('test.mat','alpha');
    whos
    alpha
    

    Another thing that helps is to initialize the variable before a call to load

    function test_func
    alpha = 0;
    load('test.mat');
    whos
    alpha
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a value int called score and i want to save this to
I have an array which contains 12 numbers and I want to save this
So.. I have a buffer with MP3 data (If I would save this buffer
I have setup my windows in a certain way. How do I save this
Example form, https://stackoverflow.com/questions/ask and I save this page to desktop. Then I edit the
I have List of particular class. I want to save this List at a
I have an object that I save like this in my controller: @user =
I save picture from UIImagePicker this way: Save picture in file and then I
I save picture from UIImagePicker this way: Save picture in file and then I
I do this to save new invoince in my Invoices database table: // insert

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.