How can I load out the data to array from several specific column number?
5 次查看(过去 30 天)
显示 更早的评论
I want to load out some specific data from my txt. file to array and I know the column number of data which I want to load out.
EX. column: 20, 86, 150, 235, 375, 568 ...
It's two rows of data file.
I have no idea on how to do.
Thanks for the help!
0 个评论
回答(1 个)
Shashi Kiran
2024-8-20
编辑:Shashi Kiran
2024-8-20
You can extract specific columns from the text file using the following approach:
data = load('your_file.txt');
% Specify the columns you want to extract
columns = [20, 86, 150, 235, 375, 568];
% Extract the specified columns from the data
selectedData = data(:, columns);
Just replace 'your_file.txt' with the actual name of your file.
Hope this helps!
2 个评论
Shashi Kiran
2024-8-20
The Error suggests that the readmatrix is reading only 7 columns from the text file.
If you could share the corresponding text file I would help further.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!