How do I multiply different sized vectors together?

I am attempting to use repmat() to continue a pattern of data so I can multiply the same sized arrays. Angle is single column, three row array that varies from 10,20,30 degrees. Height is only 500mm or 300mm in a single column and two row array. e is an array from 0.5 to 1 in 0.01 increments. How can I manipulate these arrays so that I can use the equation for distance (d) below? Thanks :)
e = [0.5:0.01:1];
THETA = load('ExcelWorkspace', 'Angle');
H = load('ExcelWorkspace', 'Height');
theta = repmat(THETA,1,51)
h = repmat(H,1,51)
d = 2*h.*sin(2*theta)*(e*(cos(theta).^2)-sin(theta).^2).*(1+e)

답변 (1개)

David Hill
David Hill 2022년 4월 22일
e = 0.5:0.01:1;
h = [300 500];
a = [10 20 30];
[E,H,theta]=meshgrid(e,h,a);%all combinations into the same sized matrices
d = 2*H.*sind(2*theta).*(E.*(cosd(theta).^2)-sind(theta).^2).*(1+E);

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

질문:

2022년 4월 22일

답변:

2022년 4월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by