Concatenate all arrays from a field in a structure
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
AnirudhNA
am 13 Apr. 2023
Bearbeitet: Stephen23
am 13 Apr. 2023
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 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 Kommentare
Siehe auch
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!