Monday 15 April 2013

automatically get the name vectors saved in the workspace in Matlab -



automatically get the name vectors saved in the workspace in Matlab -

i have multiple vectors (+100) have been loaded matlab workspace, write script can plot , save them all, need name, question is: there way automatically name vectors saved in workspace.

thanks in advance.

step one: whoever gave *.mat file 100+ named variables in it, [censored strong language , scenes viewers may find upsetting]. partly joking here; if find in sort of situation because has gone terribly wrong upstream. can work around it, though.

step two: utilize who filename list of variables in file

names = who('-file', 'all');

step three: load variables (or subset of them) struct

data = load('all.mat');

step four: utilize dynamic construction naming extract data:

for n = 1:length(names); plot(data.(names{n})); % or whatever want info end

i utilize loop dump info in cell array create farther processing simpler , avoid farther utilize of dynamic field names or worse, eval.

matlab

No comments:

Post a Comment