GeoRay
GeoRay

Reputation: 71

Replace values within matlab matrix using column values from another matrix

I have a big matrix (8656x25960) with some speckle noise within it. I used the findpeaks tool in order to find in what columns I indeed have peaks above a certain threshold. The output of the findspeaks tool is a matrix containing all of the bad columns, for example -

loc =

  Columns 1 through 6

          30          51         155         307         333         338

  Columns 7 through 12

         642         955        1409        1567        1728        1730

  Columns 13 through 18

        2332        2546        2615        2685        2806        2995

  Columns 19 through 24

        3002        3122        3124        3164        3690        4176

  Columns 25 through 30

        4430        4475        4539        5142        5155        5244

  Columns 31 through 36

        5246        5941        5943        6114        6486        6922

  Columns 37 through 42

        7165        7169        7460        7587        7647        8944

  Columns 43 through 44

       12754       13693

How can I use those columns numbers with the original matrix and replace the values of this 'bad' column with the value 0 (for example). Hoping I'm clear enough.

Upvotes: 0

Views: 47

Answers (1)

Paolo
Paolo

Reputation: 26230

For row vector Ioc simply use indexing:

yourmatrix(:,Ioc) = 0;

Upvotes: 1

Related Questions