Using loop to read column from excel sheet

17 visualizaciones (últimos 30 días)
An Van
An Van el 27 de Abr. de 2020
Respondida: Raunak Gupta el 2 de Mayo de 2020
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?

Respuesta aceptada

Raunak Gupta
Raunak Gupta el 2 de Mayo de 2020
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

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by