Reference to non-existent field 'Gait_0002'.

1 回表示 (過去 30 日間)
Muhammad Hadyan Utoro
Muhammad Hadyan Utoro 2022 年 1 月 7 日
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

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 1 月 7 日
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)))
  1 件のコメント
Muhammad Hadyan Utoro
Muhammad Hadyan Utoro 2022 年 1 月 8 日
Thank you, Sir! I made it. Appreciate your help

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by