Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're looking for <a href="http://www.mathworks.nl/help/matlab/ref/eval.html" rel="nofollow">eval</a>, but that would probably still require a loop (yes you could generate a lengthy command, but do you really want that?):</p> <p>Loop (please do not use this!):</p> <pre><code>for ii=1:numel(parvals) eval([parstrs(ii) '=parvals(' ii ')']); end </code></pre> <p><code>eval</code> is most of the time totally not needed and discouraged; changing to cells is much easier to manage and use. You already have the variables in a vector, what's the problem with just using indexing to inspect them?</p> <p>You should explain your application a bit more, so we can understand what you're really after, <em>why</em> you really want to use this kind of variable assignment.</p> <p>For exporting variables outside from a gui to the base matlab environment, you can switch to <a href="http://www.mathworks.nl/help/matlab/ref/evalin.html" rel="nofollow">evalin</a>, and use it as follows:</p> <pre><code>function main_gui() % do your thing, generate some values parvals = [1 2 3]; % now is the time to export give_me_my_vars({'a','b','c'}); % note that the following function is nested: function give_me_my_vars(parstrs) for ii=1:numel(parvals) evalin('base',[parstrs(ii) '=' parvals(ii)]); end end end </code></pre> <p>This is only possible for simple scalars, which fit in a string. I think you actually want to look for something to switch variables from one workspace to another (gui to base), but I don't know if that'd be possible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload