[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need help setting a flag once in sub.m when called from main.m
From: |
Svante Signell |
Subject: |
Need help setting a flag once in sub.m when called from main.m |
Date: |
Tue, 09 Mar 2010 09:29:21 +0100 |
Hi,
I have the following problem:
I need to call a subfunction once from the main function, setting a flag
that it has been called. This should work as long as the workspace is
not cleared. I can solve it by a persistent variable in the subfunction
but it is not a nice solution.
Code below:
main.m:
<how to declare status here?>
status = sub(status);
or
status = sub();
sub.m:
function status = sub(status)
or
function status = sub()
if ( strcmp (status,'yes') ~= 1)
do stuff;
printf ('sub.m: setting status flag')
status = 'yes';
end
Calling main in the interpreter:
main
sub.m: setting status flag
main
<no output>
etc
clear all
main
sub.m: setting status flag
etc
Thanks,
Svante
- Need help setting a flag once in sub.m when called from main.m,
Svante Signell <=