Reference to non-existent field 'Gait_0002'.

2 Ansichten (letzte 30 Tage)
Muhammad Hadyan Utoro
Muhammad Hadyan Utoro am 7 Jan. 2022
Hello everyone,
I had a trouble sorting out data from a cell into a structure. So, I'd like to include the data from previous cell into a new structure, but this keeps popping out:
Reference to non-existent field 'Gait_0002'.
Error in ImportingData (line 21)
Data.EMG.(gait{j}) = Data.Gait{i}.(gait{j}).Analog.Data(3:12,:)';
Here are my codes:
% Defining Files
filenames = {'Bridge_2_0001';'Lunge_R_0001';'Squat_2_0001';'Lunge_L_0001'};
filestem = 'Gait_000';
gait = ["Gait_0001" "Gait_0002" "Gait_0003" "Gait_0004" "Gait_0004" "Gait_0005" "Gait_0006" "Gait_0007"];
muscles = ["RF_L", "RF_R" "ST_L" "ST_R" "GA_L" "GA_R" "TA_L" "TA_R" "VL_L" "VL_R"];
% Load Files
for i = 1:7
for j = 1:numel(filenames)
for m = 1:10
Data.Gait{i} = load(strcat(filepath,filestem,num2str(i)));
Data.(char(filenames{j})) = load(strcat(filepath,filenames{j}));
Data.EMG.(gait{j}) = Data.Gait{i}.(gait{j}).Analog.Data(3:12,:)';
end
end
end
I really appreciate your help.
Thanks

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 7 Jan. 2022
It would appear that Data.Gait{i} does not containt a fieldname Gait_0002.
You are using your loop counter i, so it is hard to say which file does not have this fieldname, but when you get the error, check the value of i, and then run the following to determine which file to inspect.
load(strcat(filepath,filestem,num2str(i)))

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by