what is the problem with the code?
Afficher commentaires plus anciens
clc;
close all;
clear all;
% The variabel
L0 = 0.5;
k = 10;
AO = 0.3;
Hyp = 0.8 ;
BD = Hyp * sind(20) + 0.3;
DP = BD/2;
OD = 0.8 * cosd(20);
DBdiff = (BD/2) - (AO/2);
Sl = sqrt((OD^2) + (DBdiff^2));
DeltX = Sl - L0;
F = k * DeltX;
alpha = atand(DBdiff/OD)
%OA Part
Sx = F * cosd(alpha)
Sy = F * sind(alpha)
%SUMFx=0 -> Ax + Ox + Sx = 0
%SUMfy=0 -> Oy - Ay + Sy = 0
%SUMM0=0 -> T + (0.15)(Sx)-(0.3)(Ax) = 0
%BD Part
Px = -F * acosd(alpha)
Py = -F * asind(alpha)
%SUMFx=0 -> Dx + Bx - Px = 0
%SUMFy=0 -> Dy - By - Py = 0
%SUMM0=0 -> (DP)(Px) + (Bx)(BD) = 0
%AB Part
F1 = 0.3 * 10 * 1/2
F2 = 0.3 * 5
F1x = F1 * cosd(70)
F2x = F2 * cosd(70)
F1y = F1 * sind(70)
F2y = F2 * sind(70)
%SUMFx=0 -> Ax + Bx + F1x + F2x = 0
%SUMFy=0 -> -Ay - By - F1y - F2y = 0
%SUMMa=0 -> -F1y(Hyp-(2/3)*0.3*cosd(20)) - F2y(Hyp-(1/2)*0.3*cosd(20)) -
%By(Hyp) + Bx(BD-AO) - F1x(0.6 * sind(20)) - F2x(0.65 * sind(20)) = 0
M = [1 0 0 0 1 0 0 0 0
0 -1 0 0 0 1 0 0 0
-(0.3) 0 0 0 0 0 0 0 1
0 0 1 0 0 0 1 0 0
0 0 0 -1 0 0 0 1 0
0 0 (BD) 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0
0 -1 0 -1 0 0 0 0 0
0 0 (BD-AO) -(Hyp) 0 0 0 0 0]
N= [-Sx;
-Sy;
-(F1)*(Sx);
Px;
Py;
-(DP)*(Px);
-(F1x) -(F2x);
(F1y) + (F2y);
(F1y)*(Hyp-(2/3)*0.3*cosd(20))+(F2y)*(Hyp-(1/2)*0.3*cosd(20))+(F1x)*(0.6*sind(20)) + (F2x)*(0.65*sind(20));]
X = M\N
2 commentaires
Vladik Berg
le 3 Mar 2022
Torsten
le 3 Mar 2022
N= [-Sx;...
-Sy;...
-(F1)*(Sx);...
Px;...
Py;...
-(DP)*(Px);...
-(F1x)-(F2x);...
(F1y)+(F2y);...
(F1y)*(Hyp-(2/3)*0.3*cosd(20))+(F2y)*(Hyp-(1/2)*0.3*cosd(20))+(F1x)*(0.6*sind(20))+(F2x)*(0.65*sind(20))];
Réponse acceptée
Plus de réponses (1)
Cris LaPierre
le 3 Mar 2022
Modifié(e) : Cris LaPierre
le 3 Mar 2022
There is ambiguity in one of your rows and, since the code is building an array, MATLAB is not doing what you intended. Specifically, a '-' can indicate subtraction as well as a negative number. Since you are building an array, how you use your spaces matters.
The problem is in this line:
-(F1x) -(F2x);
Because of the spacing inside square brackets, this is being treated as two negative numbers rather than a subtraction. Either of the following fixes that.
-(F1x)-(F2x);
% or
-(F1x) - (F2x);
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!