hi!! I am at the end of my project, please help me.

I have two rows ft=[0 0 -1 0 -1 -1] and st=[0 0 -1 0 0 -1] I want the position of equal elements i.e for 0 when comparing both the rows, I want position as 1 2 4 as my answer.
ft=[0 0 -1 0 -1 -1]
st=[0 0 -1 0 0 -1]
pos= 1 2 4 (expected answer).
I am trying to use
pos=find(bitand(ft,st)==0);
but getting this error
Double inputs must have integer values in the range of ASSUMEDTYPE.
I know this error is because of '-1'. Is there any other way to find the position.

 Réponse acceptée

pos = find( ft==0 & st==0 );

4 commentaires

Rutika Titre
Rutika Titre le 30 Nov 2015
Modifié(e) : Walter Roberson le 30 Nov 2015
Thank-you Sir,It worked.In this I got the position of equal number. For getting the number of equal elements I am using
mxt=sum(bitand(~ft,~st));
ft=[0 0 0 0 0]
st=[0 0 -1 0 0]
mxt=4;
suppose my
ft=[0 0 -1 0 -1 -1]
st=[0 0 -1 0 0 -1]
mxt=3;
will my logic of sum and bitand is it correct?? Please do let me know , and is there any easier way to my ouput?
mxt = sum(ft == st);
Thank-You sir, I actually wanted for only zero elements not -1. That is why I had used ~ sign.What you suggested is for even -1 I want only for 0 elements.Like in second example I want mxt=3 ; Your answer is giving me mxt=5.
sir I have used mxt = sum(ft==0 & st==0);this is working. Thank-you for your help.It helped me a lot as I was working on it since a month.I hope now my project will end till tomorrow.Thank you thank you thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by