MATLAB: How can i do loops (for cycles) with struct

for cyclesstruct

Hi, I'm not so practical with Matlab but I need to do a for cycle with a matrix composed by struct (it is 1×91 cells, each one is a struct 1×1) because I loaded on Matlab 91 matrices 1000×512 and I joined them into a single struct.
I don't know how to do the cycle because occurs an error that says: Dot indexing is not supported for variables of this type.
The for cycle I've done is as usual, and so:
for i=1:numel(matrix_of_structs)
matrix_of_structs(i).vector=fft(matrix_of_structs(i).vector)
end
Maybe I'm so dumb…. But I can't reach this problem
Thank you in advance

Best Answer

"... a matrix composed by struct (it is 1x91 cells, each one is a struct 1x1) ..."
What you describe sounds like a 1x91 cell array of scalar structures, not a single structure array. So you will need to use cell array indexing to access each structure within the cell array, e.g.:
matrix_of_structs{i}
% ^ ^ access the content of the cell array
"...because I loaded on Matlab 91 matrices 1000x512 and I joined them into a single struct"
But what you described is a cell array of structures, not a single structure array. If the structures all have the same fields then you can easily convert your cell array into a structure array:
nonscalar_structure = [cell_array_of_scalar_struct{:}]
I recommend doing this, as then you can use very convenient syntaxes for accessing your data, including the syntax that you show in your question: