I don't understand why my code is displaying 1x1 sym rather than numbers. I just don't know where I went wrong.

4 views (last 30 days)
clc; clear; close all;
%We have to figure out the lengths for all of the bars
%The distance formula is D = sqrt(((x2-x1)^2)+((y2-y1)^2))
fprintf('These are the lengths for each of the pieces\n');
fprintf('\n');
LAB=sqrt(((-58.97-0)^2)+((-12.14-0)^2));
LBD=sqrt(((-108.21+58.97)^2)+((-86.31+12.14)^2));
LCDE=sqrt(((-185.96+35)^2)+((-107.94+70)^2));
LCF=sqrt(((-334+185.96)^2)+((-74.27+107.94)^2));
LFG=sqrt(((-312+334)^2)+((90+74.27)^2));
fprintf('Length AB = %x cm\n',LAB);
fprintf('Length BD = %x cm\n',LBD);
fprintf('Length CDE = %x cm\n',LCDE);
fprintf('Length CF = %x cm\n',LCF);
fprintf('Length FG = %x cm\n',LFG);
fprintf('\n');
%Now we can use the length values to calculate the volumes
%But first we have to find the volume of each of the round tips of each bar
%The two tips form a full circle with a radius of 10cm or 0.1m and a
%thickness of 5cm or 0.05m
VTIP=pi*(10^2)*(5);
fprintf('Now we can use the length values to calculate the volume of each bar\n');
fprintf('\n');
VAB=(((LAB)*(20)*(5))+VTIP);
VBD=(((LBD)*(20)*(5))+VTIP);
VCDE=(((LCDE)*(20)*(5))+VTIP);
VCF=(((LCF)*(20)*(5))+VTIP);
VFG=(((LFG)*(20)*(5))+VTIP);
fprintf('Volume AB = %x cm^3\n',VAB);
fprintf('Volume BD = %x cm^3\n',VBD);
fprintf('Volume CDE = %x cm^3\n',VCDE);
fprintf('Volume CF = %x cm^3\n',VCF);
fprintf('Volume FG = %x cm^3\n',VFG);
fprintf('\n');
%now we can find the mass of each bar
%The density I am using for the steel alloy is 0.00775 kg/cm^3
DEN=0.00775;
fprintf('Now we can find the mass of each bar');
fprintf('\n');
MAB=(VAB*DEN);
MBD=(VBD*DEN);
MCDE=(VCDE*DEN);
MCF=(VCF*DEN);
MFG=(VFG*DEN);
fprintf('Mass AB = %x kg\n',MAB);
fprintf('Mass BD = %x kg\n',MBD);
fprintf('Mass CDE = %x kg\n',MCDE);
fprintf('Mass CF = %x kg\n',MCF);
fprintf('Mass FG = %x kg\n',MFG);
fprintf('\n');
%now we can find the weights
fprintf('Now we can find the weight of each bar');
fprintf('\n');
g=9.81;
WAB=MAB*g;
WBD=MBD*g;
WCDE=MCDE*g;
WCF=MCF*g;
WFG=MFG*g;
fprintf('Weight AB = %x N\n',WAB);
fprintf('Weight BD = %x N\n',WBD);
fprintf('Weight CDE = %x N\n',WCDE);
fprintf('Weight CF = %x N\n',WCF);
fprintf('Weight FG = %x N\n',WFG);
fprintf('\n');
%I'm just calculating the mass of the casting really quick
WCASTING=100;
MCASTING=WCASTING/g;
fprintf('Mass of the casting is %x kg\n',MCASTING);
fprintf('\n');
%Now we are going to find the vector components for each bar at the first
%position
ABxi=-58.97-0;
AByi=-12.14-0;
BDxi=-108.21+58.97;
BDyi=-86.31+12.14;
CDExi=-185.96+35;
CDEyi=-107.94+70;
CFxi=-334+185.96;
CFyi=-74.27+107.94;
FGxi=-312+334;
FGyi=90+74.27;
%Now we have to solve for all the reaction forces
syms Ax Ay Bx By T Dx Dy Cx Cy Ex Ey Fx Fy Gx Gy;
e1 = -Ax + Bx == 0;
e2 = Ay - By - WAB == 0;
e3 = -(ABxi*By) - (AByi*Bx) + T == 0;
e4 = -Bx + Dx == 0;
e5 = By - Dy - WBD == 0;
e6 = -(BDxi*Dy) - (BDyi*Dx) == 0;
e7 = -Dx + Cx + Ex == 0;
e8 = -Ey + Dy + -Cy - WCDE == 0;
e9 = -(CDExi*Cy) - (CDEyi*Cx) == 0;
e10 = -Cx + Fx == 0;
e11 = Cy - Fy - WCF - WCASTING == 0;
e12 = -(CFxi*Fy) - (CFyi*Fx) == 0;
e13 = Gx - Fx == 0;
e14 = -Gy + Fy - WFG == 0;
e15 = -(FGxi*Gy) - (FGyi*Gx) == 0;
sol1 = solve([e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15],[Ax, Ay, Bx, By, T, Dx, Dy, Cx, Cy, Ex, Ey, Fx, Fy, Gx, Gy]);
display(sol1);
%Now we are going to find the vector components for each bar at the second
%position
ABxf=60.182-0;
AByf=1.716-0;
BDxf=-28.793-60.182;
BDyf=4.748-1.716;
CDExf=-26.314+35;
CDEyf=-85.412+70;
CFxf=-162.536+26.314;
CFyf=18.381-85.412;
FGxf=-312+162.536;
FGyf=90-18.381;
%Now we have to solve for all the reaction forces
syms Axf Ayf Bxf Byf Tf Dxf Dyf Cxf Cyf Exf Eyf Fxf Fyf Gxf Gyf;
e16 = -Axf + Bxf == 0;
e17 = Ayf - Byf - WAB == 0;
e18 = -(ABxf*Byf) - (AByf*Bxf) + T == 0;
e19 = -Bxf + Dxf == 0;
e20 = Byf - Dyf - WBD == 0;
e21 = -(BDxf*Dyf) - (BDyf*Dxf) == 0;
e22 = -Dxf + Cxf + Exf == 0;
e23 = -Eyf + Dyf + -Cyf -WCDE == 0;
e24 = -(CDExf*Cyf) - (CDEyf*Cxf) == 0;
e25 = -Cxf + Fxf == 0;
e26 = Cyf - Fyf - WCASTING - WCF == 0;
e27 = -(CFxf*Fyf) - (CFyf*Fxf) == 0;
e28 = Gxf - Fxf == 0;
e29 = -Gyf + Fyf - WFG == 0;
e30 = -(FGxf*Gyf) - (FGyf*Gxf) == 0;
sol2 = solve([e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30],[Axf Ayf Bxf Byf Tf Dxf Dyf Cxf Cyf Exf Eyf Fxf Fyf Gxf Gyf]);
display(sol2);

Answers (1)

Walter Roberson
Walter Roberson on 13 Jul 2020
The first set of equations is inconsistent.
eqn = [e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15];
sol = solve(eqn(1:14));
E15 = subs(eqn(15), sol);
E15 = 151767382664397973517046363/294104539013337579520 == 0
In particular, e9 has consequences that are incompatible with e15
solve(eqn(9:15)) %-> empty
solve(eqn(10:15)) %-> non-empty

Categories

Find more on Oceanography and Hydrology in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!