How do I load these files using the directory and then reinvert the matrix?

2 vues (au cours des 30 derniers jours)
Laurentiu Galan
Laurentiu Galan le 13 Nov 2011
PathStr = 'c:\Users\Laurentiu Galan\Desktop\tickoutput';
Files = dir(fullfile(PathStr,'*.csv'))
for k=1:length(Files)
Data=importdata(fullfile(PathStr,Files(k).name));
end
This is the code that will load my files into a directory (thanks to Fangjun Jiang). However, I don't know how to navigate this directory. Each file is a yahoo finance .csv file that has headers in the first row: Date, Price, Adjusted Price. The values in the rows below are numbers and dates. Unfortunately, the values are backwards, i.e. the value in the second row is the information from 11/9/11. The third row is from 11/8/11, etc... How do I reorder each file so that the values from rows 2 till the end are inverted? I.E. so my second row entry is from 5/20/06 (when the data starts) and the final is from 11/9/11. FInally, how do I overwrite my existing files in the same path. SOrry, i recognize this is extensive, but I would really appreciate it. I am learning Matlab now and this is the first major project ive been given.

Réponses (1)

Image Analyst
Image Analyst le 13 Nov 2011
To flip a matrix:
m_Flipped = flipud(m);
See the FAQ http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F for info on how to batch process files.
  1 commentaire
Walter Roberson
Walter Roberson le 13 Nov 2011
Though in the case of what was asked:
m_semi_Flipped = [m(1,:); flipud(m(2:end,:))];

Connectez-vous pour commenter.

Catégories

En savoir plus sur Financial Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by