Replacing elements in a vector

2 ビュー (過去 30 日間)
AR
AR 2019 年 10 月 23 日
コメント済み: KALYAN ACHARJYA 2019 年 10 月 23 日
I have a row vector which has 400 elements. All the elements are whole numbers and fluctuate between 60-70. I want to replace the elements with numbers between 1-11. As in all elements=60 should be replaced with 1, all elements=61 should be replaced with 2.....all elements=70 should be replaced with 11 and so on and so forth.
Can someone suggest a way to do this?
Thank you.
Ahmed.

回答 (2 件)

Guillaume
Guillaume 2019 年 10 月 23 日
So, simply subtract 59 from your vector:
newvector = yourvector - 59;
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 10 月 23 日
Yes sir +1

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


KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 10 月 23 日
編集済み: KALYAN ACHARJYA 2019 年 10 月 23 日
Replacing elements in a vector
Lets row vector is data.
"As in all elements=60 should be replaced with 1"
data(data==60)=1;
%so on..
"all elements=61 should be replaced with 2."
data(data==61)=2;
%so on..

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by