Effacer les filtres
Effacer les filtres

search and find specific measured data name rows in structure and save corresponding data

2 vues (au cours des 30 derniers jours)
I'm creating code to pull TDMS data into Matlab so that I can examine and track test results.
Currently I'm able to import several files. These files are then thrown into a structure together. The result is shown:
In order to limit the scope of my question, I'll try to be brief: right now I import 5 or so files that sometimes have the same layout (eg. each row within LT(1).Data.MeasuredData matches the row within LT(2).Data.MeasuredData), however there are times when this is not the case. So I cannot simply concatenate the data from row 8 in LT(1).Data.MeasuredData(8).Data with the data from LT(2).Data.MeasuredData(8).Data and call it Discharge pressure in order to plot... Instead I would need to figure out the data based on the "Name" within each LT(1:5), store it as a variable, then concatenate these variables in order to graph.
I would like to set up code that looks within each file [LT(1:5)], finds the name "Utempra 1/Ambient (F)" (also several other variables), stores the corresponding data as a vector that I can then combine to make a complete variable through concatenation.

Réponses (1)

Vatsal
Vatsal le 21 Fév 2024
Hi,
In order to search and find specific measured data name rows in the structure and save corresponding data, you can loop through the structure array and check the "Name" field of each element within the "MeasuredData" array. When a match for the name "Utempra 1/Ambient (F)" (or any other specified variable names) is identified, the relevant data can be extracted and concatenated into a vector.
The following code snippet provides an example of how to perform this operation for the "Utempra 1/Ambient (F)" variable:
% Initialize an empty cell array to store the data
allData = {};
% Loop over all the LT structures
for i = 1:length(LT)
% Get the MeasuredData from the current LT structure
measuredData = LT(i).Data.MeasuredData;
% Loop over all the MeasuredData
for j = 1:length(measuredData)
% Check if the Name matches
if strcmp(measuredData(j).Name, 'Utempra 1/Ambient (F)')
% If it does, append the Data to the allData cell array
allData{end+1} = measuredData(j).Data;
end
end
end
% Now, allData is a cell array where each element is a vector of data
% from one of the LT structures. You can concatenate them into a single
% vector like this:
concatenatedData = vertcat(allData{:});
I hope this helps!

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by