I need a program to read data from a single file

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

hello
how are the data structured in those files , can you edit them ?
Well, so far I've got this:
%% Código Matlab Projeto
%tentativas
close all
clear all
clc
a = 'C:\Users\box\Desktop\Projeto Luis\Dados\2021';
d=dir('**/*.21I');
b=struct2cell(d);
w=b(:,1);
which gives me this:
and the structure is the following picture:
And I really don't know what I have to do now.
is this a homework ? did you get any info / advice / request about what you have to do ?
It's for a project I'm working on. Basically, the files are from TEC data (total electron content) and they're separated by 15 minutes from each other. Since there's 8117 files, I was told to build a program to easily choose what I want and then I need to be able to read the files.

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2021년 4월 8일
편집: Jan 2021년 4월 8일

0 개 추천

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

Ok, thanks mate. I'm still learning and I was told since the beggining to do it so, that's why I do it everytime.
Jan
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개)

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

질문:

2021년 4월 7일

편집:

Jan
2021년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by