How do I load these files using the directory and then reinvert the matrix?
조회 수: 2 (최근 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.
댓글 수: 0
답변 (1개)
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
2011년 11월 13일
Though in the case of what was asked:
m_semi_Flipped = [m(1,:); flipud(m(2:end,:))];
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!