Filter löschen
Filter löschen

How to read columns from matlab with different number of rows

2 Ansichten (letzte 30 Tage)
I need to read all the numeric data from several columns of twelve excels. I'm referring specifically that I'd like to code a loop where I could save in a matrix all the data. For example, I create an array called "energia_activa" and there I have to save the column C of each excel. The problem is that each excel has a different number of rows so when I am reading them with a loop an error related to the dimmensions of the matrix in the left side and right side appears. How can I solve it?
On the other hand, one of the column of each excel I have to import has in several of the excels empty cells so when I am reading them an error appears as well. I'd be very grateful if you could help me.
Thank you in advance.
meses = ["enero 2019.xlsx","febrero 2019.xlsx", "marzo 2019.xlsx", "abril 2019.xlsx", "mayo 2019.xlsx", "junio 2019.xlsx", "julio 2019.xlsx", "agosto 2019.xlsx", "septiembre 2019.xlsx", "octubre 2019.xlsx", "noviembre 2019.xlsx", "diciembre 2019.xlsx"];
%ENERGÍA ACTIVA
dimensiones = zeros(1,12);
for i=1:12
dimensiones(1,i)=size(xlsread(meses(i),'C:C'),1);
end
energia_activa = zeros(max(dimensiones),12);
for i=1:dimensiones(i)
energia_activa(:,i)=xlsread(meses(i),'C:C')
end
  2 Kommentare
Mathieu NOE
Mathieu NOE am 2 Dez. 2020
hello José
could you share also the xlsx files ?
tx
José Javier Rubio Rubio
José Javier Rubio Rubio am 2 Dez. 2020
Hi Mathieu,
Of course. I must keep their names and the columns which I am interested in are C, D, F and G. Column D has several empty cells in some of the excels and it brings some error. Moreover, column F is alphanumeric.
Thank you.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by