フィルターのクリア

How to enter intermittent entries in a vector

1 回表示 (過去 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.
  1 件のコメント
Waheeb Butt
Waheeb Butt 2020 年 11 月 25 日
Thanks alot, it helped :)

サインインしてコメントする。

採用された回答

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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by