Extract data using variable names
Show older comments
Hello Matalab Community.
Let me ask your help to find out a way to improve porcessing my data.
I have files with lots of variables, data Type is structure.

I want to analyze data, let's say I want to review VSPD so I used below commadns:
%extract data, convert to double
V_Time = VSPD.time;
V_VSPD = VSPD.signals.values;

Now I can easly use double data to plot it or do something else.
Becasue I got several files to go through and saveral variables, I'm trying to create a code to make this process faster:
clear all; % Clears all memory
clc; % Clears the command window screen
fprintf('select folder containing data files\n');
currentpath=pwd; %%Identify current folder
[FileName,PathName] = uigetfile('@*.mat','Select the .dat-file(s)','MultiSelect','on');
if (PathName == 0)
fprintf('Data directory was not selected...script will be terminated\n\n');
return
end
cd(PathName);
files=dir('@*.mat');
num_files=length(files(:,1));
for i=1:num_files
fprintf('Progress: %d/%d\n\n',i, num_files)
load(files(i,1).name)
end
FileName = files.name;
PathName = files.folder;
if isnumeric(FileName)
return
end
FileName = cellstr(FileName);
V = { ...
'VSPD'...
};
N = numel(FileName);
my goal is to create a list of the variables that I want to use(extract) for my analysis in this case V
Then use V to somehow create V_Time = VSPD.time and V_VSPD = VSPD.signals.values;
A = cell2mat(V);
B= '.time';
C= '.signals.values';
AA = [A C];
BB = convertCharsToStrings(C);
CC = BB;
%%V_Time = A + C ?????
any feedback will be highly appreciated
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!