How to remove a value from matrix with same values in different positon?
Show older comments
Hi everyone. I have 3x3 matrix of
T = [7,8,8 ; 6,4,10 ; 12,8,7]
I want to remove seven at first row and first column and not the other 7 in the last row and last column. How to remove it and same will apply for 8 also. I used indexing as T(T==7) = NaN; but it removes both values as the condition implies. Kindly please help with this. Thanks in advance.
6 Comments
dpb
on 7 Dec 2019
Unless there some other logical condition to use other than the row, you simply use the row index in the expression...
T(T(1,:)==7)=nan;
etc., ...
Pandiyaraj Gnanasekar
on 7 Dec 2019
No, we don't.
The above works for the Q? as asked; you'll have to illustrate the actual problem if that isn't the real question.
If it's simply iterating over a row index, there's nothing to prevent substituting the loop index (or any other) variable for the constant in the indexing expression.
But, as noted above, you have to have some codable logic by which to decide what row is to be operated on (and what value to substitute, etc., ...).
Matlab is general coding language; you can do virtually anything you can imagine but you first must be able to define what that something is...which isn't clear for the general case here.
Pandiyaraj Gnanasekar
on 7 Dec 2019
What are n, m in the two loop limit expressions intended to be? They're undefined here.
"...schedule the minimum job first and next minimum job ..."
Why isn't the order just sort(minV) then?
T=sort(minV);
After that, ETime and STime will just be
Etime=cumsum(T);
Stime=[0;Etime(1:2)];
it would seem.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Mobile in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!