Effacer les filtres
Effacer les filtres

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

5 vues (au cours des 30 derniers jours)
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 commentaires

Connectez-vous pour commenter.

Réponse acceptée

Wayne King
Wayne King le 10 Oct 2012
Modifié(e) : Wayne King le 10 Oct 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 commentaires
Walter Roberson
Walter Roberson le 8 Mar 2022
MATLAB has no implied multiplication so you need .* between the ) and the (
Torsten
Torsten le 8 Mar 2022
Modifié(e) : Torsten le 8 Mar 2022
... and only round brackets () instead of square brackets [].

Connectez-vous pour commenter.

Plus de réponses (1)

Wayne King
Wayne King le 10 Oct 2012
Modifié(e) : Wayne King le 10 Oct 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 commentaires
Wayne King
Wayne King le 10 Oct 2012
Modifié(e) : Wayne King le 10 Oct 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by