How to insert and analyze as signal a column from a txt file.

7 views (last 30 days)
Anastasios Kyriakopoulos
Anastasios Kyriakopoulos on 11 Jan 2022
Commented: Mathieu NOE on 2 Feb 2022
Hi everyone,have a happy new year,i am a new member in this community and this is my first question.
I am a master student,my problem is that i am trying to insert a set of data given from a set of txt files in order to analyze them in the context of an assing in a subject.
Data are given in a set of txt files and must be taken from a specific column of each file for exmaple 1st or 5ht.Each column data are a time domain amplitude counting and the function that are composing must be analyzed with a plenty of diagnostical tools like fast fourier transform,wavelet denoiser etc ,and must be extracted from this analysis a planty of caracteristics like rms values,cyrtosisvalues etc
My problem is that the apps of each tool doesn't give neither the option to insert data directely from a text file,nor to extract characteristics from them.
I found a list with proper commands in order to make my assing.If you can help me in order to find something i would appriciate it
Thanks a lot from your time.

Answers (1)

Mathieu NOE
Mathieu NOE on 13 Jan 2022
hello and welcome in this forum !
here a starter - how to list and import multiple txt files - after remains to implement your own code for data analysis
if you want the file names / folders be sorted in natural order (what matlab fail to do) , you need to use the function natsortfiles , which is available in the File Exchange section (FEX in short) : Natural-Order Filename Sort - File Exchange - MATLAB Central (mathworks.com)
clc
clearvars
S = dir('**/*.txt');
S = natsortfiles(S); % natsortfiles now works on the entire structure
%% main loop
for k = 1:numel(S)
foldername = S(k).folder;
filename = S(k).name;
F = fullfile(foldername, filename);
data = importdata(F, ' ', 2); % or any other function adapted to data loading
%%%% your code here %%%%%%%%
end

Tags

Community Treasure Hunt

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

Start Hunting!