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

조회 수: 1(최근 30일)
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.

답변(1개)

Image Analyst
Image Analyst 2011년 11월 13일
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
Walter Roberson
Walter Roberson 2011년 11월 13일
Though in the case of what was asked:
m_semi_Flipped = [m(1,:); flipud(m(2:end,:))];

댓글을 달려면 로그인하십시오.

범주

Find more on Search Path in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by