Replacing elements in a vector

2 vues (au cours des 30 derniers jours)
AR
AR le 23 Oct 2019
Commenté : KALYAN ACHARJYA le 23 Oct 2019
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.

Réponses (2)

Guillaume
Guillaume le 23 Oct 2019
So, simply subtract 59 from your vector:
newvector = yourvector - 59;
  1 commentaire
KALYAN ACHARJYA
KALYAN ACHARJYA le 23 Oct 2019
Yes sir +1

Connectez-vous pour commenter.


KALYAN ACHARJYA
KALYAN ACHARJYA le 23 Oct 2019
Modifié(e) : KALYAN ACHARJYA le 23 Oct 2019
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..

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by