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

 채택된 답변

DGM
DGM 2021년 10월 31일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2021년 10월 31일

댓글:

2021년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by