Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare matrix elements

Status
Not open for further replies.

gkiom

Electrical
Joined
Nov 30, 2006
Messages
4
Location
GR
Hi all. I'm new in matlab and i want to do smth like that:

Having two matrixes(vectors is better), like

A=[1;2;6;3;5;8]
B=[4;6;9;7;4;5]

I want to compare all elements of A to B, and if an element of A is same with one of B (not in same position necessarilly) to be written in another vector. In this example, i want to create a vector like

C=[6;5]

I spent many hours reading help documentation on matrixes but to no avail. I found smth like 'any' but did not understand it's functionality, and especially if it feets my needs.

Is this ....SO difficult...? I do not suppose so, but is there anyone here available to show me how?

Thanx in advance.
 
Sorry I cannot matlab but I would search for max (or min )element in both vectors. If not equal I would reject them or overwrite with zero. If equal, then transfer them into a new vector.Loop to the last element.
m777182
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top