How do I compare matrices of different sizes in Matlab?

Asked

Viewed 33 times

1

I have two matrices with numeric values: A (size 44x1) and B (size 42x1).

What I need to do is:

  • count how many times the values appear repeated for A and B.
  • whether these repeating values are common in the two matrices, if yes, divide their counts.

Example: 0.5 appears 600 vzs in matrix A and 300 vzs in matrix B, then divides 600 by 300. 0.7 appears 200 vzs in matrix A and 100 vzs in matrix B, then divides 200 by 100.

At the end I need to have two columns: one with the repeated numbers and the other with the division values.

| 0.5 | 2 | 
|:---- |:------:|
| 0.7 | 2   | 

In python it looks like this:

import pandas as pd

data1 = pd.read_excel('C:/Users/Desktop/Python/data1.xlsx')

data2 = pd.read_excel('C:/Users/Desktop/Python/data2.xlsx')

for i in data1['Mag'].value_counts() & data2['Mag'].value_counts():

  a = data1['Mag'].value_counts()/data2['Mag'].value_counts()

  print(a)

  break

How do I do in English? Thanks!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.