Extracting data file in workspace from a table/files

16 visualizzazioni (ultimi 30 giorni)
I have a folder (Measurement_1) of 120 data files in CSV format where each data file has the data of three sensors under name A, B, C). The final goal is to run the algorithm over each data file.
- I have started to import the data from the folder into matlab.
- Using the code
files = dir('*.csv');
tables = {};
for i = 1:length(files)
tables{i} = readtable(files(i).name);
end
I got three items in the work space
files 120x1 struct
i 120
tables 1x120 cell
Now, how can I extract the my 120 data recordings/files that are under different names such as
- sensors A, line_1
- sensor A, node_4
-sensor X, point_7X
.
.so on till 120
I am basic user of matlab, any help will be appreciated, many thanks.

Risposte (1)

Walter Roberson
Walter Roberson il 15 Lug 2020
  3 Commenti
Walter Roberson
Walter Roberson il 15 Lug 2020
When you said,
Now, how can I extract the my 120 data recordings/files that are under different names such as
- sensors A, line_1
- sensor A, node_4
-sensor X, point_7X
are things like "sensors A, line_1" the file names? Or are they the names of columns? Perhaps "sensor A, line_1" and "sensor A, node_4" are intended to refer to the same file "sensor A.xlsx" and you want to extract variables "line_1" and "node_4" from those?? How is it determined what will need to be extracted?
When I read your question, I thought what you were asking was to create workspace variables named after the files, so the content of "sensor A, line_1" would be expected to be stored into a variable named something like "sensor_A_line_1" . That is the sort of practice that is discouraged: creating workspace variables named according ot data content is not a good idea. But now looking back, I realize I do not understand what it is that you actually want to do with the data once it is read in ??
Khan Engr
Khan Engr il 16 Lug 2020
Just to mention that this issue is sloved now, thanks.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by