How would you read a specific channel in a tdms file in matlab?

2 views (last 30 days)
How would you call a specific channel in a struct that has been generated from a TDMS file.
In the attached picture I use convertTDMS to create a struct file. How do I go about this:-
Finding the index to match a name so that I can plot the data associated with that name?
for example how would you find the index of the string 'Synchronous/Air Manifold Pressure' in the Name and plot the coinciding data fo that Name?

Accepted Answer

Voss
Voss on 27 Mar 2022
If you might have any number of elements of the struct array data.Data.MeasuredData whose 'Name' field is 'Synchronous/Air Manifold Pressure', one way to plot their Data is:
idx = find(strcmp({data.Data.MeasuredData.Name},'Synchronous/Air Manifold Pressure'));
for ii = idx(:).'
plot(data.Data.MeasuredData(ii).Data);
hold on
end
If instead you know there will always be exactly one element of the struct array data.Data.MeasuredData whose 'Name' field is 'Synchronous/Air Manifold Pressure', you can make it simpler:
plot(data.Data.MeasuredData(strcmp({data.Data.MeasuredData.Name},'Synchronous/Air Manifold Pressure')).Data);

More Answers (0)

Categories

Find more on Instrument Connection and Communication in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!