Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How can I read a data, in a txt file, as a matrix?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am working on a deep learning project and for the first step, I need to read a txt file as a matrix so that I can reach every features easily.
I have 90 classes and 42 features for each of them:
{feature1, feature2, ..., feature42}
{feature1, feature2, ..., feature42}
......
{feature1, feature2, ..., feature42}
The features starts after the keyword '@DATA' in the txt file
I can read the first row with this one. Since the keyword '@DATA' starts at line 47, I am reading the line 48. For sure, I also need to read the other lines until the end of the file. However, before that, I tried to see whether I can read the first row correctly or not.
% open the file
fid=fopen('BlindAllFeatures.txt');
% set linenum to the desired line number that you want to import
linenum = 48;
% use '%s' if you want to read in the entire line or use '%f' if you want to read only the first numeric value
C = textscan(fid,'%s',1,'delimiter','\n', 'headerlines',linenum-1);
But I am getting a 1x1 cell that has the whole {feature1, feature2, ..., feature42} when I run this code. You can see it from the image I uploaded. I need 90 rows and 42 columns but I couldn't do that. If I can do that, I will try to train them by trying different classifiers and after that, I will move on to feature selection part. I hope you can help me. Thank you.
댓글 수: 0
답변 (1개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!