How to separate alternate elements from an array?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rebeka
am 27 Aug. 2022
Kommentiert: Rebeka
am 27 Aug. 2022
I have a matrix.
A=[1 2 3 4 5 6 7 8]
I want to separate the alternate elemets from the array.
I tried to do this,
N=[1 2 3 4 5 6 7 8];
Th1=zeros(4,0);
Th2=zeros(4,0);
for i=1:1:8
if mod(i,2)==0;
Th1=N(i);
else
Th2=N(i);
end
end
I am sure solution must be very simple. But, the code seems to save only the last values. Any help?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!