Concatenate all arrays from a field in a structure
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a structure with a size 1 x 10845 and 4 fields. Each of the 10845 values consists of arrays with various lengths.
The struct is named S and it looks like this:

I want to extract all these values and concatenate them into a new array. So essentially, I want 4 different arrays for the four fields, consisting of all the values in the struct, put together as a long array.
I've tried to implement the code with the following for loop, but I get the error
for 1 = 0:length(S.A)
A_combined = S.A(i);
end
"Error using length
Too many input arguments."
I've also tried using arrayfun(@(x) copy(x.A), S);
but I get the following error:
"Undefined function 'copy' for input arguments of type 'double'."
I've been struggling with this problem for a few days now and I can't find the solution. Do I have the wrong approach or am I missing something?
0 Commenti
Risposta accettata
Più risposte (1)
Image Analyst
il 13 Apr 2023
Did you try
allA = [S.A]
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
We can't test our code with an image of your variable, we need the actual variable.
0 Commenti
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!