Can I Recall Variables for Several Times?
4 views (last 30 days)
Show older comments
Elliot Lee
on 30 Nov 2013
Answered: Image Analyst
on 30 Nov 2013
I've been trying to recall the variables. Since I use the same bunch of coefficients through many script files, I have to copy and past the very first lines of code again and again. And I thought this is not efficient so i've tried to recall a user defined function that contains the recurring lines of defining the variables. But the function does not save the variable into workspace. Isn't there, in matlab, any cool way to use a sort of object thing in Java?
thanks,
0 Comments
Accepted Answer
Image Analyst
on 30 Nov 2013
Have the function return the variables. If there are lots of them, you can return a structure if you want
function UserSettings = DefineUserSettings(handles)
UserSettings.value = 10;
UserSettings.lastUsedFolder = pwd;
set(handles.txtFolder, 'String', UserSettings.lastUsedFolder);
% or whatever.....
Then whenever you need to run it, just call it like this:
UserSettings = DefineUserSettings(handles);
handles is optional of course, and you can pass in other things if you'd rather. If you're using GUIDE, then having handles will allow you to initialize controls on your GUI.
0 Comments
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!