Hi, im new to MatLab
i have two matrixes with different sizes. One is 36832x1(A) and the other is 931029x1(B).
I have to devide the A through B. I tried to shorten B through calculating averages, but it is very difficult to get the same length as A as result.
Maybe someone has a small hint because I think im only missing a key word for finding the correct solution.
Thanks

 Réponse acceptée

A = randi(9,1,10) % a short vector
A = 1×10
8 3 1 7 1 6 1 8 7 8
B = randi(9,1,17) % a long vector
B = 1×17
4 9 5 8 4 1 7 2 4 6 4 1 6 4 6 5 5
% interpolate to shorten the long vector
Bs = interp1(1:numel(B),B,linspace(1,numel(B),numel(A)),'linear')
Bs = 1×10
4.0000 5.8889 5.7778 3.0000 2.2222 5.7778 2.0000 5.1111 5.7778 5.0000
C = A./Bs % divide or something
C = 1×10
2.0000 0.5094 0.1731 2.3333 0.4500 1.0385 0.5000 1.5652 1.2115 1.6000

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by