lambr0 and zeta0 outputting 1x1 answer when I want them to output 1x7 answer, any suggestions?
1 view (last 30 days)
Show older comments
x = [-0.4:0.05:0.4]
r3 = 0.750
r4 = 1.031
a0 = 14.04
L0 = sqrt((r3^2)+(r4^2)-(2*r3*r4*cosd(90+14.04)))
del0 = acosd(((r3^2)+(L0^2)-(r4^2))/(2*r3*L0))
lamb0 = acosd(((r4^2)+(L0^2)-(r3^2))/(2*r4*L0))
L = sqrt((x.^2)+(L0^2)-(2*x*L0*cosd(del0)))
lambr0 = acosd(((r4^2)+(L.^2)-(r3^2))/(2*r4.*L))
zeta0 = acosd(((L.^2)+(L0^2)-(x.^2))/(2*L0.*L))
0 Comments
Answers (1)
Steven Lord
on 12 Sep 2023
In addition to using element-wise power (the .^ operator) and element-wise multiplication (the .* operator) you need to use the element-wise division operator ./ instead of the array operator.
x = [-0.4:0.05:0.4];
r3 = 0.750;
r4 = 1.031;
a0 = 14.04;
L0 = sqrt((r3^2)+(r4^2)-(2*r3*r4*cosd(90+14.04)));
del0 = acosd(((r3^2)+(L0^2)-(r4^2))/(2*r3*L0));
lamb0 = acosd(((r4^2)+(L0^2)-(r3^2))/(2*r4*L0));
L = sqrt((x.^2)+(L0^2)-(2*x*L0*cosd(del0)));
lambr0 = acosd(((r4^2)+(L.^2)-(r3^2))./(2*r4.*L)); % Note ./ instead of /
zeta0 = acosd(((L.^2)+(L0^2)-(x.^2))./(2*L0.*L)); % Ditto
whos lambr0 zeta0
I suspect you had a typo in the title of your post where you said you expected a 1-by-7 answer, since x is 1-by-17 and therefore lambr0 and zeta0 should both be 1-by-17 as well.
I didn't add the dot before the / in the equations for del0 or lamb0 because all the variables used there are scalars. In that case, / and ./ behave the same.
x = [1./2, 1/2]
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!