MATLAB Answers

How do I read multiple text files and use its data for mathematical Calculation?

1 view (last 30 days)
mujtabaxaidi on 14 Sep 2021
Answered: Walter Roberson on 15 Sep 2021
I have approximately 60 files for input signal and 60 files for Reference signal and I need the values stored in these files to calculate Transmission coeffiecient wrt time. Files contain data as follow
0, 102
and so on.
It will be great if someone can help me out.

Answers (1)

Walter Roberson
Walter Roberson on 15 Sep 2021
ext = '.txt'; %extension of files
dinfo = dir("*" + ext);
filenames = {};
nfiles = length(filenames);
all_data = cell(nfiles,1);
for K = 1 : nfiles
thisfile = filenames{K};
thisdata = load(thisfile);
all_data{K} = thisdata;
The data is now in the cell array all_data .
Or you could process the data as you read it.



Community Treasure Hunt

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

Start Hunting!