I need a program to read data from a single file
2 ビュー (過去 30 日間)
古いコメントを表示
I'm doing a research project for my space weather project, and I have a lot of data files (.21I) separated by folders. With the function "dir" I can now see all the files as a list, but now I need to be able to read the data from a single file. How do I do it?
4 件のコメント
Mathieu NOE
2021 年 4 月 8 日
is this a homework ? did you get any info / advice / request about what you have to do ?
採用された回答
Jan
2021 年 4 月 8 日
編集済み: Jan
2021 年 4 月 8 日
Omit the brute clearing header:
close all
clear all
clc
This is not useful in productive code and I cannot imagine why it is recommended such frequently to beginners.
Use a function instead, to keep the workspace clean.
Folder = 'C:\Users\box\Desktop\Projeto Luis\Dados\2021';
FileList = dir(fullfile(Folder, '**', *.21I'));
for iFile = 1:numel(FileList)
File = fullfile(FileList(iFile).folder, FileList(iFile).name);
% Now import this File as needed:
...
end
2 件のコメント
Jan
2021 年 4 月 8 日
編集済み: Jan
2021 年 4 月 10 日
Yes, it happens frequently that teachers tell their students to use this brute clearing header. clear all removes all loaded functions from the memory such that they have to be read again from the slow disk. This wastes a lot of time without any benefits. I'm afraid the teachers simply repeat what they have been told when they have been students, although they do not understand, what the code does. This is called "cargo cult programming", which is a widespread programming anti-pattern.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Web Services についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!