save values in array
Ältere Kommentare anzeigen
I have
A={[1,6,3,2],[3,5,6]};
all_el =[];
for i=1:length(A)
all_el(end)=A{i}
end
I want to have this result
all_ell=[1,2,3,5,6]
Akzeptierte Antwort
Weitere Antworten (1)
Sriram Tadavarty
am 16 Mär. 2020
Bearbeitet: Sriram Tadavarty
am 16 Mär. 2020
1 Stimme
Hi there,
It is not pretty clear as what you wanted to do.
To get the desired output, perform the following:
A={[1,6,3,2],[3,5,6]};
% With for loops
all_el =[];
for i=1:length(A)
all_el=[A{i} all_el];
end
all_el = unique(all_el);
% Without for loops
all_el = unique([all_el{:}])
Hope this helps.
Regards,
Sriram
Kategorien
Mehr zu Install Products finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!