Borrar filtros
Borrar filtros

Dividing a sine function with scalar values - why do i get a complex double vector?

5 visualizaciones (últimos 30 días)
Hello all,
please have a look on the following code:
if true
% %%ZUWEISUNG NEUER VARIABLEN
Gemessene Daten
delta_v = Delta_V_40_20;
v_ohne_d = V_400x2D200x25GeschwindigkeitAlteFederOhneD0xE4mpfer_Red;
v_mit_d = V_400x2D200x25GeschwindigkeitAlteFederMitD0xE4mpfer_Red;
a_ohne_d = a_400x2D200x25BeschleunigungAlteFederOhneD0xE4mpfer_Red;
a_mit_d = a_400x2D200x25BeschleunigungAlteFederMitD0xE4mpfer_Red;
Berechnungsdaten
m = 16.6; % Masse [kg]
b = 170; % Länge [mm]
c = 30; % Länge [mm]
x2 = 200; % Länge [mm]
x1 = 301; % Länge vom Drepunkt zum Schwerpunkt
BERECHNUNG VERÄNDERLICHE LÄNGE DES DÄMPFERS
a = sqrt(b^2+c^2-2*b*c*cos(Winkel))-b;
BERECHNUNG KRAFT F1, F2, F3
y = asin((c*sin(Winkel))./a);
F1 = m * delta_a;
F2 = F1 * x1/x2;
F3 = F2 ./ sin(y); % y meint den winkel omega end
why is F3 a complex double vector? I´d like to have F3 over the angle y.
Thanks
  3 comentarios

Iniciar sesión para comentar.

Respuesta aceptada

Wayne King
Wayne King el 10 de Oct. de 2012
Editada: Wayne King el 10 de Oct. de 2012
The issue is that in your asin(), you have values outside of [-1,1] that is what is causing your output, y, to be complex-valued.
For example:
asin(2)
Real-valued sin() and cos() are bounded by 1, that is not true for complex-valued sin() and cos(), so when you give asin() a value outside of [-1,1], MATLAB correctly returns a complex number.
  3 comentarios
Walter Roberson
Walter Roberson el 8 de Mzo. de 2022
MATLAB has no implied multiplication so you need .* between the ) and the (
Torsten
Torsten el 8 de Mzo. de 2022
Editada: Torsten el 8 de Mzo. de 2022
... and only round brackets () instead of square brackets [].

Iniciar sesión para comentar.

Más respuestas (1)

Wayne King
Wayne King el 10 de Oct. de 2012
Editada: Wayne King el 10 de Oct. de 2012
I do not see that you show us how you get Winkel in cos(Winkel), so we cannot reproduce the issue, but I suspect that your expression
a = sqrt(b^2+c^2-2*b*c*cos(Winkel))-b;
is producing a complex-valued output because you are taking the sqrt() of a negative number.
Please provide Winkel if that is not the case.
  2 comentarios
Wayne King
Wayne King el 10 de Oct. de 2012
Editada: Wayne King el 10 de Oct. de 2012
You have values that you are feeding asin() that are outside the interval, [-1 ,1], see my answer below. Asking for the inverse sine of a number outside of [-1,1] correctly results in a complex number.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by