MATLAB Answers

Regarding use of index to obtain the required code (Target avoiding loops)

1 view (last 30 days)
Shashi
Shashi on 24 Jan 2012
Query: Suppose i have a bigger matrix (in my case image) named as I. Now, i make a function as
[r,c,v]=find(I>128);
Now i have got the index of rows and columns in two different arrays. Now, i want to extract all those values from bigger matrix for those corresponding rows and columns and multiply those values with a value (let it be x)..and all other values which are not in [r,c] to be multiplied by (let it be 'y')
Can you suggest something for it, without going through for loop.
What i tried was this:
Given: r= array of rows stored size=[p,1] c=array of columns stored=[p,1] I is the original matrix (image in my case)
Implementation:
h=I(r,c); h2=diag(h); h2=h2*x; p=I-h2; p=p*y;
Well, i did try this but the result was ambiguous. Is there some better way to implement this. I am able to do it through loops but i want to implement through matrices only.
All suggestions are most welcome.

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.