how to choose right index
Ältere Kommentare anzeigen
Dear All,
I have this matrix X and this is the index for it. I want to take the row with 1 1 index to empty and plot the remind points, but I got wrong
Y =[1.7797 1.3341
1.5067 0.5390
1.0709 1.0732
1.2872 1.0745
0.3687 1.4166
0.4112 0.2333
1.4512 0.8961
1.9749 1.6645];
idx =[0 1
0 1
1 1
1 1
0 1
0 0
1 1
0 0];
m=8;
for i=1:1:m
if idx(i,1:1:end)==1
Y(i,:)=[]
end
m=size(Y,1)
end
plot(Y(:,1),Y(:,2),'.r');
I know my problem with the if condition, I don't know who to write it correct. Can anyone help me please.
Regards, imola
regards
3 Kommentare
Geoff Hayes
am 16 Feb. 2015
Imola - please provide some context surrounding your code. What is the relationship between the first block and the second block? Add some comments so that we can get an idea of what it is you are trying to accomplish.
imola
am 16 Feb. 2015
Image Analyst
am 16 Feb. 2015
You say "I have this matrix X" - what matrix X???? And if idx(i,1:1:end)==1 gives a vector. I think you want to use all().
Akzeptierte Antwort
Weitere Antworten (1)
Y = Y(sum(idx, 2) ~= 2, :);
plot(Y(:,1), Y(:,2), '.r')
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!