Using loop to read column from excel sheet
17 次查看(过去 30 天)
显示 更早的评论
Hello, I am working on data processing.
I have an excel sheet that contains hundreds of subjects.
My job is to analyse the data from each subjects and compare them. So far, I have finish import and analyse first several subjects.
Since each column is a subject, I use "xlsread('mini_project_normalRR.mat.xlsx',1,'A:A');" to read each of them.
I want to ask if there is a loop function that could help me read through each column and perform the exact analysis for the rest of the data? And record the analyse into a separate table?
0 个评论
采纳的回答
Raunak Gupta
2020-5-2
Hi,
You can use readmatrix instead of xlsread. readmatrix will return a matrix from the ‘.xlsx’ file that will contain column of each subject as required. From that you can iterate into the columns and do the required processing on each column. Following code can help you get started.
data = readmatrix('mini_project_normalRR.mat.xlsx');
numColumn = size(data,2);
result = zeros(size(data));
for idx = 1:numColumn
subject = data(:,idx);
% Your processing code on each column goes here
% Output of analysis is let say same length vector as of subject
% Assign it a matrix with corresponding coloumn number
% Lets say analysisResult is the result of one column.
result(:,idx) = analysisResult;
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!