MATLAB Answers

Using filenames to name timetables

1 view (last 30 days)
Karin Kvickström
Karin Kvickström on 4 Sep 2020
Answered: Deepak Meena on 7 Sep 2020
Hi,
I have a number of files apples.txt, orange.txt, pear.txt (+ a lot more). Each file is a measurement and the first vector is the time in seconds and the others are coords at that time.
I want to import these files to timetables to analyze them using the Signal Analyzer. This means that I can't use a struct since the Signal Analyzer only accepts timetables.
I know you are not supposed to do this but I want an easy way to import text files with different names to timetables with those same names.
I have easily imported them all to a structure but it doesn't help me when it comes to the analysis.

  3 Comments

Stephen Cobeldick
Stephen Cobeldick on 4 Sep 2020
Given that the Signal Analyzer is an interactive tool, how do you imagine to use it on all of those files?
Why not import the data into one variable?
Karin Kvickström
Karin Kvickström on 7 Sep 2020
I would like to plot the results against each other in the signal analyzer, which means that they need to have different variable names.
Stephen Cobeldick
Stephen Cobeldick on 7 Sep 2020
"...which means that they need to have different variable names."
No it doesn't. According to the documentation here:
the signalAnalyzer app supports any number of input arrays with this syntax:
signalAnalyzer(sig1,...,sigN)
which you can easily provide via a comma separated list:
C = {sig1,sig2,...,sigN}; % import this data in a loop
signalAnalyzer(C{:})
Learn more:

Sign in to comment.

Answers (1)

Deepak Meena
Deepak Meena on 7 Sep 2020
Hey Karin,
As per my understanding, you want to convert .txt file into a timetable. First you might need to make sure that .txt file is in correct format to convert into timetable. Input files must contain datetime or duration vector for row times.
Now once you do that, we can convert into timetable in two steps:
  1. First convert .txt file into table
  2. Now we can covert the table into timetable by:
oranges = readtable("oranges.txt"); %%Step 1
oranges = table2timetable(oranges); %% step 2
For more Information you can refer to the following documentation:
  1. readtable
  2. table2timetable
Now you can visualize all the signals together as:
signalAnalyzer(oranges,pear,apples);

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!