Loading .mat file content into base workspace by calling load function within a gui callback function

I can't load the data I want into base workspace (although they appear perfectly in the command window) for furthe use. I use Load function within a gui callback function and I think this what makes loading process difficult. To be more specific, I need to load variables tmp and specs into base workspace, any ideas? Please see the attached screenshot for more details. Many thanks

4 个评论

Why do you need variables in the base workspace if you are using a GUI? Or why are you using a GUI if you are working in the base workspace?
Functions have their own workspace, this can be shared between GUI callbacks in different ways.
If you really want to do what you are asking then
doc assignin
should help, though it is not an approach I recommend and points towards bad design in general.
I use assignin and evalin currently but I know, as you said, they are not recommended. I thought there must be better solution.
Thanks very much Stephen, I could not find something organised like what you provided to explain this topic. Much appreciated.

请先登录,再进行评论。

 采纳的回答

I'm confused about the "import filename.*" .
It is ugly and you find many threads - hundreds - about suggestions to avoid the remote creation of variables. Such methods impede the debugging drastically. So don't do this!
But if you are willing to apply this:
assignin('base', 'Act_specs', tmp);
assignin('base', 'specs', tmp.Act_Specs);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by