Looping for finding dominating points.
Mostra commenti meno recenti
Hi,
I have a matrix with 'n' rows and two columns, say,
f(1,1) f(1,2)
f(2,1) f(2,2)
f(3,1) f(3,2)
f(4,1) f(4,2)
............
f(n,1) f(n,2)
I would like to remove dominating row or rows, and record non-dominating rows as a data file. It would be much appreciated if any one can help me with coding to do that.
Thanks in advance.
Rizvi
2 Commenti
Yu Jiang
il 30 Ago 2014
How do you define a 'dominating row'?
Mohammed Rizvi
il 31 Ago 2014
Risposta accettata
Più risposte (1)
Image Analyst
il 30 Ago 2014
Try this:
% Define rows to remove:
% However they're determined....I don't know, presumably you do.
% For this demo, let's assume you've identified the rows
% and the row numbers are entered into an array.
dominatingRows = [2,3,42,69,123]; % For example...
% Now, remove the dominating rows:
f(dominatingRows, :) = [];
2 Commenti
Mohammed Rizvi
il 31 Ago 2014
Image Analyst
il 31 Ago 2014
Now it's clear - would have been great to have given that definition in your original post. Try this:
rows = 30; % Whatever you want.
columns = 3; % Whatever you want.
f = rand(rows, columns) % Create sample data.
df = diff(f) % Calc diff between each row and one below it.
% Find where all 3 differences are positive.
dominatingRows = sum(df>0, 2) == size(df, 2)
% Extract only the non-dominating rows.
out = f(~dominatingRows,:)
Categorie
Scopri di più su Sparse Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!