Why wont MATLAB let my plot using linspace?

1 view (last 30 days)
clear all; close all; clc
F=5;D=7;E=2;
% AB, AX, BX, BC, CX, CW, CV, CD, DE; 9
% DV, EV, EU, ET, EF, FG, FT, GR, GT; 18
% GS, GH, HI, HR, IJ, IR, IP, IQ, JK; 27
% JP, KL, KP, KN, KO, LM, LN, NM, NO; 36
% OP, PQ, QR, RS, ST, UT, VU, WV, WX; 45
% Hoist, Fx, Fy; 48
dc = cosd((16+F)/2);
ds = sind((16+F)/2);
MVS = 1.73124; % Middle vertical strut length
TS = ((12+D)/12); % Top Strut
DSAX = TS/(norm([TS,MVS])); % Diagonal strut angle wrt horizontal axis
DSAY = MVS/(norm([TS,MVS]));
Truss = zeros(48);
increase = [];
for x = linspace(0.68,1.38,100)
Load = (1881/2)*x;
Truss(1,[1,2,47]) = [1*(dc),1*(dc),1]; % Point A in x and y direction
Truss(2,[1,2,48]) = [1*(ds),-1*(ds),1];
Truss(3,[1,4]) = [-1*(dc),1*(dc)]; % Point B in x and y direction
Truss(4,[1,3,4]) = [-1*(ds),-1,1*(ds)];
Truss(5,[4,5,7,8]) = [-1*(dc),-1*cosd(69),1*cosd(79.5),1*(dc)]; % Point C in x and y direction
Truss(6,[4,5,6,7,8]) = [-1*(ds),-1*sind(69),-1,-1*sind(79.5),1*(ds)];
Truss(7,[8,9]) = [-1*(dc),1]; % Point D in x and y direction
Truss(8,[8,10]) = [-1*(ds),-1];
Truss(9,[9,11,13,14]) = [-1,-1*DSAX,1*DSAX,1]; % Point E in x and y direction
Truss(10,[11,12,13]) = [-1*DSAY,-1,-1*DSAY];
Truss(11,[14,15]) = [-1,1]; % Point F in x and y direction
Truss(12,[16]) = [-1];
Truss(13,[15,17,18,20]) = [-1,1*DSAX,-1*DSAX,1]; % Point G in x and y direction
Truss(14,[17,18,19]) = [1*DSAY,-1*DSAY,-1];
Truss(15,[20,21]) = [-1,1]; % Point H in x and y direction
Truss(16,[22]) = [-1];
Truss(17,[21,23,24,25]) = [-1,1,-1*DSAX,1*DSAX]; % Point I in x and y direction
Truss(18,[24,25,26]) = [-1*DSAY,-1*DSAY,-1];
Truss(19,[23,27,46]) = [-1,1*(dc),-1*cosd(4)]; % Point J in x and y direction
Truss(20,[27,28,46]) = [-1*(ds),-1,1*sind(4)];
Truss(21,[27,29,30,31]) = [-1*(dc),1*(dc),-1*cosd(79.5),1*cosd(69)]; % Point K in x and y direction
Truss(22,[27,29,30,31,32]) = [1*(ds),-1*(ds),-1*sind(79.5),-1*sin(69), -1];
Truss(23,[29,33]) = [-1*(dc),1*(dc)]; % Point L in x and y direction
Truss(24,[29,33,34]) = [1*(ds),-1*(ds),-1];
Truss(25,[33,35]) = [-1*(dc),-1*(dc)]; % Point M in x and y direction
Truss(26,[33,35]) = [1*(ds),-1*(ds)];
Truss(27,[31,35,36]) = [-1*cosd(69),1*(dc),-1*(dc)]; % Point N in x and y direction
Truss(28,[31,34,35,36]) = [1*sind(69),1,1*(ds),-1*(ds)];
Truss(29,[36,37]) = [1*(dc),-1*(dc)]; % Point O in x and y direction
Truss(30,[32,36,37]) = [1,1*(ds),-1*(ds)];
Truss(31,[25,30,37,38]) = [-1*DSAX,1*cosd(79.5),1*(dc),-1]; % Point P in x and y direction
Truss(32,[25,28,30,37]) = [1*DSAY,1,1*sind(79.5),1*(ds)];
Truss(33,[38,39]) = [1,-1]; % Point Q in x and y direction
Truss(34,[26]) = [1];
Truss(35,[17,24,39,40]) = [-1*DSAX,1*DSAX,1,-1]; % Point R in x and y direction
Truss(36,[17,22,24]) = [1*DSAY,1,1*DSAY];
Truss(37,[40,41]) = [1,-1]; % Point S in x and y direction
Truss(38,[19]) = [1];
Truss(39,[13,18,41,42]) = [-1*DSAX,1*DSAX,1,-1]; % Point T in x and y direction
Truss(40,[13,16,18]) = [1*DSAY,1,1*DSAY];
Truss(41,[42,43]) = [1,-1]; % Point U in x and y direction
Truss(42,[12]) = [1];
Truss(43,[7,11,43,44]) = [-1*cosd(79.5),1*DSAX,1,-1*(dc)]; % Point V in x and y direction
Truss(44,[7,10,11,44]) = [1*sind(79.5),1,1*DSAY,1*(ds)];
Truss(45,[44,45]) = [1*(dc),-1*(dc)]; % Point W in x and y direction
% Truss(46,[6]) = [1];
%
% Truss(47,[2,5,45]) = [-1*(dc),1*cosd(69),1*(dc)]; % Point X in x and y directions
% Truss(48,[2,3,5,45]) = [1*(ds),1,1*sind(69),-1*(ds)]
Truss(46,[46]) = [14.25*sind(4)+MVS*cosd(4)];
Truss(47,[46,47]) = [-1*cosd(4),1];
Truss(48,[46,48]) = [1*sind(4),1];
%Constants Matrix
Forces = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;((Load*cosd(71))+(Load*cosd(9)));((Load*sind(71))-(Load*sind(9)));
0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;((Load*sind(9)*19.8)-(Load*sind(71)*19)-(Load*sind(71)*19.8));
((-Load*cosd(9))-(Load*cosd(71))-(Load*cosd(71)));((Load*sind(9))-(Load*sind(71))-(Load*sind(71)))];
solution = Truss\Forces; % Solving For INTERIOR Link forces
link_forces = solution([5 6])
increase = [increase,link_forces];
end
x = linspace(0.68,1.38,100);
plot(x,link_forces)
xlabel('Percent Increase of Load')
ylabel('Forces in the links identified by legend [kN]');
legend('CX','CW')
title('Change in struts with largest tension and compression Values based on load')
hold on;

Accepted Answer

Voss
Voss on 7 Dec 2021
link_forces contains just the last solution (i.e., for x == 1.38).
increase is your variable that contains all link_forces, so plot with that instead.

More Answers (0)

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!