Quantcast
Channel: MATLAB Central Newsreader - tag:"variables"
Viewing all articles
Browse latest Browse all 41

Creating changing variables in function workspace

$
0
0
Dear all,

I am trying to create and save some structure into a auto generated variables. I am lost as to how to assign a new variable name from this auto generated lists.

%Step 1: Create a structure.

m.a = 1; m.b = 2;

%Step 2: Create a variable name from my folder number that I have inserted into this function.

varName = [ 'dirA_' num2str(dirAname) '_dirB' num2str(dirBname) ];

%Step 3: The new variable name is whatever varName is.

[ 'dirA_' num2str(dirAname) '_dirB' num2str(dirBname) ] = m;

%Step 4: Save the folder to the directory;

I am stuck on the last stage. Any help will be much appreciated.

Rules: I can not let this variable go into my matlab workspace. It has to be in this function workspace and disappear as long as the job of this function is closed.

Viewing all articles
Browse latest Browse all 41

Trending Articles