i have the following double arrays:(adsbygoogle = window.adsbygoogle || []).push({});

165 7077

165 7045

165 5175

168 7305

168 3487

169 6196

169 10213

170 7048

165 7077

165 7045

168 5175

169 7305

169 3487

170 6196

170 10213

170 7048

how do i obtain the number and percentage of common values in column 2 of array1 and array2 by the unique values in column 1?

for which i wrote the code:

x = unique(data2(:,1));

n = length(data1);

percent = [];

for i = 1:length(x)

count = 0;

for j = 1:n

if data1(j) == x(i)

count = count+1;

end

end

percent=[percent;[count/n,x(i)]];

end

but this doesn't work. the counter is buggy in the if statement. i need to see if the second column in both the arrays are equal to each other based on the unique value in column 1. i need an output table something like:

165 %overlap

in two separate columns.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB vector intersection help

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - MATLAB vector intersection | Date |
---|---|

Python How can I run Python by getting values from Matlab | Mar 7, 2018 |

What is each step of this Matlab program doing? | Feb 21, 2018 |

C/++/# Help with MATLAB code? | Feb 9, 2018 |

3-D plot using 3 vectors in Matlab | Jul 16, 2012 |

MATLAB: 100 element vector between A and B | Jan 22, 2009 |

**Physics Forums - The Fusion of Science and Community**