Controlling a matlab script (Pause, Reset)

I am trying to create a matlab script (m-file) which shall be controlled by an external VBA script.

The matlab script shall do the same operation every time (even params change, but this is not the matter in this case) for a certain number of loops. If I see it right, I can use matlab funktions in VBA like this: http://www.mathworks.de/help/techdoc/matlab_external/f135590.html#f133975

My main problem is how to implement the matlab part of this problem...at the moment my control part looks like this:

start.m:

run = 1;
reset = 0;
while run ~= 0     % Loop until external reset of 'run' to '0'
    if reset ~= 0
        doReset();   % Reset the parameters for the processing
        reset = 0;
        disp('I did a reset');
    end

    disp('I am processing');
    doProcess();
    pause(1)
end
disp('I am done');

The reset part works very fine while changing the value by the script, but when I manually try to change the value of 'run' or 'reset' to any other value in my workspace, nothing happens...my script doen't abort, neither does the reset-if do it's work... this seems to me that the script doesn't recognize any changes in the workspace?!

later the variables 'run' and 'reset' shall be set or unset by the VBA script. Is there any plausible reason why I can't abort the loop by hand?

Thanks for any advice!

greets, poeschlorn

Edit:

It seems that the script loads the variables once before starting and never again during runtime...is there a possibility to have explicit access to a workspace variable?

Edit 2:

I use Matlab 2010b with no additional Toolboxes at the moment

Edit 3:

I found out, that there are several 'workspaces' or RAMs in Matlab. If my function is running, the variables are stored in 'base' (?) workspace, which is not the matlab workspace on which you can click and change every value. So I have to get access to this ominous 'base' space and change the flag 'run' to zero.

8
задан Cœur 28 October 2018 в 18:13
поделиться