How to enter intermittent entries in a vector

1 Ansicht (letzte 30 Tage)
Waheeb Butt
Waheeb Butt am 22 Nov. 2020
Kommentiert: Waheeb Butt am 25 Nov. 2020
Hi, I need a bit of your help please. Consider I have a vector A = [a1 a2 a3 a4], and another vector B=zeros(2*length(A)). I want to put the entries of A into B as follows:
B = [a1 a2 0 0 a3 a4 0 0]. Intermittent entries. I hope I am able to convey clearly the requirement. Awaiting the kind response.

Akzeptierte Antwort

Nora Khaled
Nora Khaled am 22 Nov. 2020
a=1:1:6;
v=[];
for i=1:2:length(a)
v=[v a(i) a(i+1) 0 0] ;
end
v

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by