필터 지우기
필터 지우기

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

조회 수: 5 (최근 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
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
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