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

2 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

Wayne King
Wayne King 2012-10-10
编辑:Wayne King 2012-10-10
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 个评论

请先登录,再进行评论。

更多回答(1 个)

Wayne King
Wayne King 2012-10-10
编辑:Wayne King 2012-10-10
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 个评论
Wayne King
Wayne King 2012-10-10
编辑:Wayne King 2012-10-10
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by