Info
This question is closed. Reopen it to edit or answer.
How can I read a data, in a txt file, as a matrix?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!