Deleting slices in 3D array structure containing cell array fields

1 Ansicht (letzte 30 Tage)
ErikaZ
ErikaZ am 19 Feb. 2020
I have several 3D structures with the following notation
Array(1:17,1:10,1:50).fields{1,1:10}(2,:)
I need to delete the contents of the followinf slices in all the fields of all the arrays
Array([9 11],[2 5 10],[16 30]).fields
I have tried several codes but I get different errors such as:
Deletion requires an existing variable.
Expected one output from a curly brace or dot indexing expression, but there were 500 results.
Subscripted assignment dimension mismatch.
I have tried, compressed code, for loops, eval, alternatives to not use eval but nothing works. Here is my last code:
ite= {'test_targets', 'test_inputs', 'predicted_outputs', 'perf', 'abs_error_angle', 'abs_error_moment', 'RMSE_angle', 'RMSE_moment'};
condition ={'narxwalk','EMG1walk','EMG2walk','EMGwalk','vel1walk','vel2walk','vel3walk','inputswalk','anglewalk', 'momentwalk', 'outputswalk', 'narxup', 'EMG1up', ...
'EMG2up','EMGup','vel1up','vel2up','vel3up','inputsup','angleup','momentup','outputsup','narxdown','EMG1down','EMG2down','EMGdown','vel1down','vel2down', ...
'vel3down','inputsdown','angledown','momentdown','outputsdown','velwalk','EMGoutwalk','veloutwalk','velup','EMGoutup','veloutup','veldown','EMGoutdown', 'veloutdown'};
for i = 1:length(ite)
for pi = [9 11]
for sw = [2 5 10]
for hL = [16 30]
for K = 1 : length(condition)
if isempty(eval([ite{i},'(',num2str(pi),',',num2str(sw),',',num2str(hL),').',condition{K}]))
continue
else
eval([ite{i},'(',num2str(pi),',',num2str(sw),',',num2str(hL),').',condition{K}])=[];
end
end
end
end
end
end
But I get
Deletion requires an existing variable.
But I know the variable exists because if I check
eval([ite{i},'(',num2str(pi),',',num2str(sw),',',num2str(hL),').',condition{K}])
it does show the contents of the structure.
I don't know that I am missing.
Thank you.

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