Only last data in struct? How to load all data in struct?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello.
How can you avoid overwriting data in struct? Data struct now only provides data of last file in EMG. Normally there are 6 files of EMG. How can I put all of them in a struct?
Thanks.
%% load EMG data
myFolder = 'E:\**\Assignment_V3\Data'
if ~isfolder(myFolder)
errormessage = sprintf('Error: The folder does not exist');
myFolder = uigetdir();
if myFolder == 0
return;
end
end
filePattern = fullfile(myFolder, '**/EMG/*.mot');
pathway = dir(filePattern);
for k = 1:length(pathway)
EMGfile = pathway(k).name;
EMGcorrectfile = fullfile(pathway(k).folder, EMGfile);
fprintf(1, 'Now reading %s\n', EMGcorrectfile);
EMGdata = importdata(EMGcorrectfile);
end
0 Commenti
Risposte (1)
Image Analyst
il 13 Dic 2020
Attach 2 different .mot files so we can run your code.
In the meantime, try this untested code:
% Load EMG data
myFolder = 'E:\**\Assignment_V3\Data'
if ~isfolder(myFolder)
errormessage = sprintf('Error: The folder does not exist');
myFolder = uigetdir();
if myFolder == 0
return;
end
end
filePattern = fullfile(myFolder, '**/EMG/*.mot');
pathway = dir(filePattern);
for k = 1:length(pathway)
EMGfile = pathway(k).name;
EMGcorrectfile = fullfile(pathway(k).folder, EMGfile);
fprintf(1, 'Now reading %s\n', EMGcorrectfile);
EMGdata = importdata(EMGcorrectfile);
EMGstruct(k).data = EMGdata; % Add a structure to the structure array.
end
2 Commenti
Image Analyst
il 13 Dic 2020
If it worked for you and your problem is now solved, then you can thank us answerers by "Accepting the answer". Thanks in advance.
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!