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;

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by