필터 지우기
필터 지우기

How to enter intermittent entries in a vector

조회 수: 2 (최근 30일)
Waheeb Butt
Waheeb Butt 2020년 11월 22일
댓글: Waheeb Butt 2020년 11월 25일
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.

채택된 답변

Nora Khaled
Nora Khaled 2020년 11월 22일
a=1:1:6;
v=[];
for i=1:2:length(a)
v=[v a(i) a(i+1) 0 0] ;
end
v

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by