How to read columns from matlab with different number of rows

5 ビュー (過去 30 日間)
José Javier Rubio Rubio
José Javier Rubio Rubio 2020 年 12 月 2 日
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 件のコメント
Mathieu NOE
Mathieu NOE 2020 年 12 月 2 日
hello José
could you share also the xlsx files ?
tx
José Javier Rubio Rubio
José Javier Rubio Rubio 2020 年 12 月 2 日
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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by