File run from pushbutton not using updated workspace values as inputed in a GUI
Show older comments
Hi,
I've made a GUI using GUIDE which takes values from an initial parameters sheet, allows a user to edit them and then runs the initial parameters file again with these new variables.
The file should then calculate a few variables (which aren't available to be edited by the user) using the new, user selected values.
The GUI displays the original values fine, and when I click a 'save' button I can see that the newly selected values are saved into the workspace.
However, if I then click a 'calculate' button the equations in the file give the same values as the start.
This isn't due to re-initialising the variables back to their original value when the file is run, as I have added a couple of
if (exist(var1)==1)
var1=var1;
else
var1=5;
end
where 5 is the original value, and the variables aren't switching back to their original ones as they were before i put these loops in.
If I exit the GUI and then run the file it does use the saved, user inputed values and the calculations change.
When I run it using the GUI, it says that the variables aren't defined, even when they're in the workspace... Which doesn't make any sense to me, because it's happy to take the values from the workspace when run normally (not through GUI)
Why aren't the equations using the new, saved values in the workspace when I run it from the GUI?
Thanks!
The code in the calculate callback is simply:
run('initial_parameters.m')
Accepted Answer
More Answers (0)
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!