フィルターのクリア

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

5 ビュー (過去 30 日間)
Florian
Florian 2012 年 10 月 10 日
編集済み: Torsten 2022 年 3 月 8 日
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 件のコメント
Florian
Florian 2012 年 10 月 10 日
if true
% Winkel = (1:1:106)';
end
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 10 日
What does that mean?

サインインしてコメントする。

採用された回答

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 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 8 日
MATLAB has no implied multiplication so you need .* between the ) and the (
Torsten
Torsten 2022 年 3 月 8 日
編集済み: Torsten 2022 年 3 月 8 日
... and only round brackets () instead of square brackets [].

サインインしてコメントする。

その他の回答 (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 件のコメント
Florian
Florian 2012 年 10 月 10 日
if true
% Winkel = (1:1:106)';
end
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 Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by