How to remove a value from matrix with same values in different positon?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Pandiyaraj Gnanasekar
am 7 Dez. 2019
Beantwortet: Roshni Garnayak
am 13 Dez. 2019
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 Kommentare
dpb
am 7 Dez. 2019
Bearbeitet: dpb
am 7 Dez. 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.
Akzeptierte Antwort
Roshni Garnayak
am 13 Dez. 2019
You can obtain the indices of the first occurrence of each value in a matrix using the ‘unique’ function. Refer to the following link for details on how to use ‘unique’:
After you obtain the indices you can find the indices which have duplicate values by using the ‘ismember’ function. Refer to the link below:
Refer to the code below to obtain your functionality:
T = [7,8,8 ; 6,4,10 ; 12,8,7];
[C, ia] = unique(T, 'first');
x = 1:numel(T);
[lic, lob] = ismember(x, ia);
T(x(~lic)) = NaN;
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!