フィルターのクリア

Replacing the contents of a matrix

1 回表示 (過去 30 日間)
Dubstep Dublin
Dubstep Dublin 2016 年 1 月 30 日
コメント済み: Star Strider 2016 年 1 月 30 日
I have a 1 dimensional matrix (1000 x 1) that consists of numbers from 0 to 63.
I would like to replace the contents of this matrix as follows:
0 --> 0
1 --> 0.5
2 --> 1
3 --> 1.5
and so on..
Can someone please show me how to do this.
Thanks

採用された回答

Star Strider
Star Strider 2016 年 1 月 30 日
It looks as though you’re just dividing every element by 2, and rounding to one decimal place.
Letting ‘v’ define your vector, this works:
Out = fix(5*v)/10;
  2 件のコメント
Dubstep Dublin
Dubstep Dublin 2016 年 1 月 30 日
It works! Thanks a lot.
Star Strider
Star Strider 2016 年 1 月 30 日
My pleasure!

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 1 月 30 日
v=[0 1 2 3 4 5]'
out=v*0.5

カテゴリ

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