How can I pass a variable to RUN function?

1 view (last 30 days)
Hi,
I am using a .m script as a scenario's parameters definition file and I want to call it inside a function. I define the script file name and path trough the function uigetfile and then call the script as following:
[FileName, PathName]=uigetfile({'*.m', 'M-files (*.m)'}, 'Pick a scenario file');
CompletePath=fullfile(PathName, FileName);
run(CompletePath);
The first time I call the function, there is no problem, but when I call it for the second time, I get the error:
??? Error using ==> run at 56
Incorrect number of right hand side elements in dot name assignment. Missing [] around left hand side is a likely cause.
The only solution I have now is to restart Matlab. It will then work a single time again.
Thank you for your help
Felix
  2 Comments
Félix B-Audet
Félix B-Audet on 5 Apr 2013
I have compared the workspaces of a successful case and a non-successful case at the error and both are identical,

Sign in to comment.

Accepted Answer

Félix B-Audet
Félix B-Audet on 5 Apr 2013
I found a solution. I changed the command line in RUN.m at line 56.
The original command is:
evalin('caller',[s ';'],'cd(cur);error(lasterr)')
Changing it by the following results in not raising a error and does what I expect it to do.
evalin('caller',[s ';'],'cd(cur);')
I will do a save as, rename it and keep the two versions of the file in my path.
Thank you.

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!