There are two aspects of the problem.
  1. How do I read a tenv3 data file? The source file can be found here.
  2. I wish to extract the data under the 4th, 9th, 11th, and 13th column, such that the first row of the extracted data should read,
" 54847 -1.187879 0.058425 0.879526".
Also can these be stored in the form of an excel file or a txt file?
Please help.

2 件のコメント

Stephen23
Stephen23 2024 年 6 月 11 日
@Vikash Pandey: can you please upload the file here.
Vikash Pandey
Vikash Pandey 2024 年 6 月 11 日
@Stephen23 The problem is almost solved now. Thanks!

サインインしてコメントする。

 採用された回答

Animesh
Animesh 2024 年 6 月 11 日

0 投票

Unfortunately, MATLAB does not recognize the '.tenv3' file extension. However, a workaround is renaming the file extension to '.txt', which enables the usage of MATLAB's standard commands to manipulate the table and achieve the intended results.
Below is an illustrative example on how to manage a '.txt' file format:
data = readmatrix('your_data_file.txt');
% Extract the 4th, 9th, 11th, and 13th columns
extracted_data = data(:, [4, 9, 11, 13]);
% Display the first row of the extracted data
disp(extracted_data(1, :));
To save the extracted data to an Excel file, you can use the writematrix function:
% Save the extracted data to an Excel file
writematrix(extracted_data, 'extracted_data.xlsx');
And to save it as a text file:
% Save the extracted data to a text file
writematrix(extracted_data, 'extracted_data.txt', 'Delimiter', ' ');

4 件のコメント

Stephen23
Stephen23 2024 年 6 月 11 日
編集済み: Stephen23 2024 年 6 月 11 日
"However, a workaround is renaming the file extension to '.txt', which enables the usage of MATLAB's standard commands..."
Renaming the file is definitely not required.
The easy, efficient, recommended approach is to simply specify the FILETYPE option:
Reading the documentation is strongly recommended.
Vikash Pandey
Vikash Pandey 2024 年 6 月 11 日
@Stephen23 The problem is solved now. Your comment was helpful.
@Animesh Your code did the job. One last question. This particular command saves the newly created xlsx file in my home folder. How can I save the xlsx file in a particular folder (say "Work") in my Desktop?
"writematrix(Extracted_Data, 'Extracted_Data.xlsx');"
Walter Roberson
Walter Roberson 2024 年 6 月 11 日
writematrix(Extracted_Data, '~/Desktop/Work/Extracted_Data.xlsx')
for Mac and Linux.
For Windows, finding the Desktop folder is a bit more complicated.
profold = fullfile(getenv('USERPROFILE'), 'Desktop', 'Work');
writematrix(Extracted_Data, fullfile(profold, 'Extracted_Data.xlsx'));
However I do not promise that this will work if the Desktop has been moved to OneDrive
Vikash Pandey
Vikash Pandey 2024 年 6 月 12 日
@Walter Roberson Thanks. Job Done.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索

製品

リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by