How do I use a loop to isolate column vectors of a matrix into separate variables
Show older comments
What I'm trying to do is strip the columns from an excel file into separate variables for analysis. I know how to do it if I know the number of columns, then I can do it manually. What i would like is to do it using a for loop. This is what I have so far:
data = xlsread(fullfile(path,file));
N = size(data,2);
M = size(data,1);
for i = 1:N
varname = strcat('data',num2str(i));
eval(sprintf('%s = %f',varname,data(:,i)));
end
any help would be greatly appreciated.
Thanks, George
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!