Plotting help, please?

Ok, so I'be this program here I've got to do for a class, all of the things it asks for are done except one, the plotting part, it's a program that calculates the angle of the position of bars 3 and 4 of a 4 bar mechanism, the thing is, I have to plot the answer to both of those angles for all 360 degrees, and when I do that, all it does is tell me it will ignore all complex numbers, and 4 horizontal lines were plotted (each angle has two possible answers), then I decided since it would ignore the complex numbers I'd just plot the absolute value for the angles, and after doing that it only plotted two angles, yet still they were completely horizontal, does anybody think they could look at that part of my code and help me find out what's wrong?
Here's the pastebin of my code (excuse the spanish, but I guess you can still understand the variables and such, also, variables suck as k1, k2..etc are already defined before this bit): http://pastebin.com/ziyxcAHy

 Accepted Answer

bym
bym on 21 Aug 2011
Change the following lines in your code to use ./ instead of /
tan3a = (-E + sqrt(E.^2 - (4 .* D .* F)))./ (2 .* D);% note ./
tan3b = (-E - sqrt(E.^2 - (4 .* D .* F)))./ (2 .* D);
tan4a = (-B + sqrt(B.^2 - (4 .* A .* C)))./ (2 .* A);
tan4b = (-B - sqrt(B.^2 - (4 .* A .* C)))./ (2 .* A);

1 Comment

Luis Ramos
Luis Ramos on 21 Aug 2011
Thank you so much for the help! This was just what I needed, thanks again for your time!

Sign in to comment.

More Answers (1)

bym
bym on 21 Aug 2011
you might try using the function
atan2()
instead of
atan()
otherwise, please provide values for k1..k5 so the program will run

1 Comment

Luis Ramos
Luis Ramos on 21 Aug 2011
The values of k1-k5 are user defined, like so:
a = input('Tamaño de la barra a: ' );
b = input('Tamaño de la barra b: ' );
c = input('Tamaño de la barra c: ' );
d = input('Tamaño de la barra d: ' );
k1 = d/a;
k2 = 1/c;
k3 = ((a^2 - b^2 + c^2 + d^2)/(2 * a * c));
k4 = d/b;
k5 = ((c^2 - d^2 - a^2 - b^2)/(2 * a * b));
I also tried using atan2(), but it says there aren't enough input arguments.

Sign in to comment.

Categories

Find more on Graphics Objects in Help Center and File Exchange

Asked:

on 21 Aug 2011

Community Treasure Hunt

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

Start Hunting!