MATLAB: Loop through the values of a list from 'who' function

前端 未结 3 1506
旧巷少年郎
旧巷少年郎 2020-12-07 05:10

I have a long list of variables in my workspace. First, I\'m finding the potential variables I could be interested in using the who function. Next, I\'d like t

3条回答
  •  春和景丽
    2020-12-07 05:54

    An example writing variables from workspace to csv files:

    clear;
    
    % Writing variables of myfile.mat to csv files
    load('myfile.mat');
    allvars = who;
    for i=1:length(allvars)
        varname = strjoin(allvars(i));
        evalstr = strcat('csvwrite(', char(39), varname, '.csv', char(39), ', ', varname, ')');
        eval(evalstr);
    end
    

提交回复
热议问题