フィルターのクリア

fill part of vector

12 ビュー (過去 30 日間)
yousef Yousef
yousef Yousef 2014 年 4 月 9 日
コメント済み: dpb 2014 年 4 月 9 日
I have a=[1 2 5 4 2 7 4 8 2 3](10 values),b=[0 1 2 3],I want to fill a so that
a=[0 1 2 3 0 0 0 0 0 0],

採用された回答

dpb
dpb 2014 年 4 月 9 日
There's nothing left so there's no point in doing anything except sotoo--
a=0; a(1:length(b))=b;
a=[b zeros(1,length(a)-length(b)];
An essentially innumerable ways to get there, choose one and go on.
  3 件のコメント
dpb
dpb 2014 年 4 月 9 日
so fix the typo of I forgot that '0' is a scaler and won't fill...
a=zeros(size(a)); a(1:length(b)=b;
surely that's not too tough.
yousef Yousef
yousef Yousef 2014 年 4 月 9 日
its perfect.Thanks a lot

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

その他の回答 (1 件)

yousef Yousef
yousef Yousef 2014 年 4 月 9 日
assume I have d=[1 3 5 6 7 8 1 4 5 10],e=zeros(5,10),I want to take only the first 4 elements of d and fit them to the first row of e
  1 件のコメント
dpb
dpb 2014 年 4 月 9 日
Basically the same thing--just use colon operator to address the elements of concern ensuring the LHS and RHS have same length of subscripting.
All of these kinds of operations are in the "Getting Started" section of the documentation under array addressing. I suggest working thru those early sections and the exercises/examples therein to get the basics down.

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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by