Prev: ANUSHKA HOT PICTURES FOR BOLLYWOOD FANS
Next: Massive difference in run-time between matlab and simulink calculations
From: AW on 29 Jul 2010 19:31 I have time consuming function that is running inside a loop, but always produces the same result. I am calling matalb externally, and i want to replace this with a .mat file. For some reason an error occurs when i replace the function results with .mat input. The error message is: ??? Error using ==> b Too many output arguments. WORKING FUNCTION a=1; [b]=long_func(a) next_func(b) INTERMEDIATE FUNCTION a=1; [b]=long_func(a) save data.mat b next_func(b) NEW FUNCTION WITH ERROR load data.mat next_func(b)
From: Walter Roberson on 30 Jul 2010 10:26 AW wrote: > I have time consuming function that is running inside a loop, but always > produces the same result. I am calling matalb externally, and i want to > replace this with a .mat file. For some reason an error occurs when i > replace the function results with .mat input. The error message is: > > ??? Error using ==> b > Too many output arguments. > > WORKING FUNCTION > a=1; > [b]=long_func(a) > next_func(b) > > INTERMEDIATE FUNCTION > a=1; > [b]=long_func(a) > save data.mat b > next_func(b) > > NEW FUNCTION WITH ERROR > load data.mat > next_func(b) newdata = load('data.mat'); next_func(newdata.b);
From: Steven_Lord on 3 Aug 2010 16:40
"AW " <scorpiow88(a)hotmail.com> wrote in message news:i2t2vt$iuk$1(a)fred.mathworks.com... > I have time consuming function that is running inside a loop, but always > produces the same result. I am calling matalb externally, and i want to > replace this with a .mat file. For some reason an error occurs when i > replace the function results with .mat input. The error message is: > > ??? Error using ==> b > Too many output arguments. > > WORKING FUNCTION > a=1; > [b]=long_func(a) > next_func(b) > > INTERMEDIATE FUNCTION > a=1; > [b]=long_func(a) > save data.mat b > next_func(b) > > NEW FUNCTION WITH ERROR > load data.mat > next_func(b) If these last two lines are in a _function_ then you have a function b visible in the scope of that function, so when MATLAB parses the function it decides that the identifier b refers to that function. The fact that a variable named b is "poofed" into the function workspace _at runtime_ doesn't matter -- MATLAB has already decided that b refers to the function, and so the function is called. Walter gave you the recommended solution in his post in this thread. You should call LOAD with an output argument and index into that output argument to extract the appropriate variable. -- 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 |