필터 지우기
필터 지우기

How do I import specific channels from multiple consecutive tdms files into workspace?

조회 수: 6 (최근 30일)
Hey there,
I'm trying to import specific channels from multiple tdms files to my MatLab workspace using tdmsDatastore. With the documentation given I can't figure out how to import just specific channels due to a lack of memory.
All tdms files in one folder are from the same measurment, during the measuremnt the data is saved into a single file when reaching 1.5 GB and a new tdms file is created. Multiple sensors are used and eachs ensor saves the data in one channel. For the analysis I'm planning I only need a few channels, which would lower the size of the imported data. I would like to read in and reassemble certain channels of the individual files. Ideally, each channel should be stored in the same struc.
The files are stored in one folder with the same name like the following: folder: "Experimental_data"; files:"Experimental_data_time";"Experimental_data_time_2";"Experimental_data_time_3";... .
How can I do so? I hope anybody can help, so far there aren't many threads on the topic of tdmsDatastore, read, etc.
Thank you very much!

답변 (1개)

Harald
Harald 2023년 10월 24일
Hi Philipp,
in the documentation, find the SelectedChannelGroup and SelectedChannels properties.
The doc example shows how to use them, e.g.:
td = tdmsDatastore("C:\data\tdms");
%...
td.SelectedChannelGroup = "Force";
If you have large data and need to work with all channels, you can also use the read command (rather than readall) and control the number of rows imported at a time by setting the ReadSize property.
Best wishes,
Harald
  댓글 수: 1
Philipp Schumann
Philipp Schumann 2023년 10월 25일
Thank you for your answer! In the meantime i used the follwoing code:
path = uigetdir;
folderName = fullfile(string(path));
ds = tdmsDatastore(folderName);
while in var all important channel names I want to extract are stored.
for i = 1:length(ds.Files)
data{i,1} = tdmsread(ds.Files(i), ...
ChannelGroupName = ds.ChannelList.ChannelGroupName(1), ...
ChannelNames = [string(var(1)) string(var(2)) string(var(3))]);
%ChannelNames = ["trigger" "force_upper_tool_chn1_z" "displacement_eddy_current"]);
DATA.Trigger = [DATA.Trigger;table2array(data{i,1}{1,1}(:,1))];
DATA.Kraft_Stempel_z = [DATA.Kraft_Stempel_z;table2array(data{i,1}{1,1}(:,2))];
DATA.Weg = [DATA.Weg;table2array(data{i,1}{1,1}(:,3))];
end
This worked fine for me

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

카테고리

Help CenterFile Exchange에서 TDMS Format Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by