Filter löschen
Filter löschen

changing values in a certain column of a matrix

25 Ansichten (letzte 30 Tage)
Evelyn
Evelyn am 4 Mai 2014
Beantwortet: sayem sujon am 16 Feb. 2022
I have a large matrix and in the fifth column I want to replace every value of 990 with 30.375, how could I do this easily? I found many similar questions but not exactly the same one and I tried to adapt the solutions to my situation but it hasn't worked yet..

Akzeptierte Antwort

Cedric
Cedric am 4 Mai 2014
Bearbeitet: Cedric am 4 Mai 2014
First, you build a logical index of all values equal to 990 in column 5:
lId = A(:,5) == 990 ;
Then you use it to index relevant elements of A (in column 5), that you set to 30.375:
A(lId,5) = 30.375 ;
Let me know if you need more information.
  5 Kommentare
Cedric
Cedric am 4 Mai 2014
Thank you Image Analyst! Yes, I could have warned, but I always thought that I would be able to come back "within a few days", and I lost track of time!
Dogiparthi Santhosh Gupta
Dogiparthi Santhosh Gupta am 4 Apr. 2021
Is the same logic applicable on a table with single column.
My problem is 'I have to replace the values of 2,3,4 in a single column of a table to 1' I tried with your logic but getting an error. Kindly suggest the perfect logic by anyone.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

sayem sujon
sayem sujon am 16 Feb. 2022
Change the value of the 3rd column to [6 9 2 5]

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by