Calculation problem. it gives value instead of array

I want to plot three bar mechanism location graph. So i wrote the formulas but when i tried to calculate teofi, it gives me only one value. The other ones is giving an array. I dont understand the problem. If you help me, i glad.

 Accepted Answer

Try using element-wise division ( ./ ) and see if that gives you the expected result.
fi = 20:pi/30:60;
r1 = 0.40;
r2 = 2;
r3 = 2;
r4 = 0.30;
A = sind(fi);
B = cosd(fi) - (r1/r2);
D = (r1/r4) * cosd(fi) - (r1.*2 + r2.*2 - r3.*2 + r4.*2) / (2*r2*r4);
teofi = 2 * atand( (A-(A.*2 + B.*2 - D.*2).*(0.5) ) ./ ( B - D ) )
teofi = 1×382
-90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000 -90.0000

1 Comment

thanks bro, you helped me alot.I changed the atand formula also. İf you want to plot, you can plot like this
teofi = 2 * atand( (A + (A.*2 + B.*2 - D.*2).*(0.5) ) ./ ( B - D ) )
plot(fi,teofi)

Sign in to comment.

More Answers (0)

Categories

Asked:

on 26 Mar 2022

Commented:

on 26 Mar 2022

Community Treasure Hunt

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

Start Hunting!