Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How can i put an date array extracted from excel in a for loop?

1 visualización (últimos 30 días)
John
John el 27 de Mzo. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi!
I extracted data from excel file (first column only with dates).
I used xlsread and then DATE=TXT(3:end,1)
Now im trying to create a table where the first two rows are called 'CouponDates' and 'CashFlow, and the rest of the columns to be all the dates present in DATE.
I typed this but it doesnt work:
z=length(DATE)
E=cell(z+2,1)
for j=1:z;
E{j+2,1}=DATE(j,1);
end
Could anybody help me?
Thanks in advance

Respuestas (2)

Image Analyst
Image Analyst el 27 de Mzo. de 2014
Forget cell arrays - too complicated. Just read into a the new data type "table" directly with the new readtable() function:
t = readtable('myWorkbook.xlsx');
There - you now have your table. You can then do pretty much anything you want with it just like it's a regular array. It's very intuitive. Try it (requires R2013b or later).

Walter Roberson
Walter Roberson el 27 de Mzo. de 2014
Without loop:
E = {[]; []; cellstr(TXT(3:end,1)) };
With loop:
z = size(DATE,1);
E = cell(z+1,1);
for j = 1 : z
E{j+2,1) = DATE(j,:); %not just column 1
end

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by