Reference to non-existent field 'Gait_0002'.
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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)))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!