Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
How can i put an date array extracted from excel in a for loop?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Image Analyst
le 27 Mar 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).
0 commentaires
Walter Roberson
le 27 Mar 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
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!