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!