Connecting two points with a curved line

I want to plot a bending moment diagram and need a curved line in my plot. If I have the (x,y) cordinates of the two points, how do I connect them with a curved line without knowing the function of the curved line(parabola)?
Capture Matlab.JPG

10 Comments

The only way to connect two points is a straight line. Connecting a collection of several points using a curve makes more sense. Kindly elaborate on your question.
Hi Sagar,
I wrote a code that analyses a beam's shear forces, bending moment and deflection. As you can see in the hand-drawn graphs below, I want to plot these graphs in my code. All I need to know is how I can plot the curve as can be seen in the moment and deflection graphs.
Capture Matlab.JPG
"I want to plot these graphs in my code"
Is this anyway or there are limitaions? Which one 1st, 2nd or 3rd?
I need to plot all three. But the first one I completed as it is straight lines.
The 2nd and 3rd one with the curved lines are the two I need help with. I have the (x,y) coordinates of the beginning and ending of the curve, but I want to know how can I change a straight line to a curved line with just the beginning and ending (x,y) coordinates.
Here is my code.
The lines I included in graphs 2 (Bending Momebt Diagram) and 3 (Deflection Diagram) should change from straight lines to curved lines. I hope this makes sense? These two are the last two paragraphs of my code. I made them bold to identify easier.
%% This script will cater for SE406 Task 4.b)
%% This code will be used to take the spans and loads and calculate the
%% forces.
%% This code will also generate the relevant diagrams.
%% This code ONLY caters for the problem in the task with the assumption
%% that the beam is in symmetry and the length of member 1 is the same
%% as member 2.
clc; clear; close all
disp ('SE406 Task 4.b Symmetrically loaded continuous beam');
%% Data input Section
disp (' ');
L = input ('Length of member 1=Length of member 2 = ');
disp (' ');
w = input ('Uniformly distributed load in kN/m = ');
disp (' ');
b = L;
disp (' ');
cg = 0;
a = (cg-b/2);
c = L-a-b;
R1 = (3/8)*w*L; %Left Support Reaction
disp ('Left Support Reaction = in kN');disp (R1);
R2 = (3/8)*w*L; %Right Support Reaction
disp ('right support reaction = in kN');disp (R2);
R3 = (10/8)*w*L; %Middle Support Reaction
disp ('Middle Support Reaction = in kN'); disp (R3);
disp ('Shear Forces, where V=shear');
disp (' ');
disp (' ');
V1 = (3/8)*w*L; %Left Shear Force
disp ('Left Shear Force= in kN');disp (V1);
V2 = (-5/8)*w*L; %Minumum Shear Force
disp ('Minimum Shear Force= in kN');disp (V2);
V3 = (5/8)*w*L; %Maximum Shear Force
disp ('Maximum Shear Force= in kN');disp (V3);
V4 = (-3/8)*w*L; %Right Shear Force
disp ('Right Shear Force= in kN');disp (V4);
disp ('Bending Moments, where M=Bending Moments');
disp (' ');
disp (' ');
M1 = (9/128)*w*L^2; %Left Bending Moment
disp ('Left Bending Moment= in kN/m');disp (M1);
M2 = -(w*L^2)/8; %Maximum Bending Moment
disp ('Maximum Bending Moment= in kN/m');disp (M2);
M3 = (3/8)*L; %Right Bending Moment
disp ('Right Bending Moment= in kN/m');disp (M3);
disp ('Deflections, where D=Deflection');
disp (' ');
disp (' ');
E= 200*10^6 ; %Modulus of Elasticity of Material
I = 500*10^6 ; %Moment of Inertia about neutral axis
D1 = -(w*L^4)/(185*E*I); %Deflection between Support 1 and 2
disp ('Deflection midway between Support 1 and 2');disp (D1);
D2 = -(w*L^4)/(185*E*I); %Deflection between Support 2 and 3
disp ('Deflection midway between Support 2 and 3');disp (D2);
% Discretization of x axis.
n = 1000; % Number of discretization of x axis.
delta_x = L/n; % Increment for discretization of x axis.
x = (0:delta_x:L)'; % Generate column array for x-axis.
V = zeros(size(x, 1), 1); % Shear force function of x.
M = zeros(size(x, 1), 1); % Bending moment function of x.
D = zeros (size(x, 1), 1); %Deflection function of x
% Data processing section
for i = 1:n+1
% First portion of the beam, 0 < x < a
if x(i) < a
V(i) = V1;
M(i) = M1*x(i);
D(i) = D1*.4125*L;
elseif a <= x(i) && x(i)< a+b
% Second portion of the beam, a < x < a+b
V(i) = V2-w*(x(i)-a);
M(i) = M2*x(i)-w*((x(i)-a)^2)/2;
elseif x(i) >= (a+b)
% Second portion of the beam, a+w < x < L
V(i) = -V3;
M(i) = M3*(L-x(i));
D(i) = D2*.4125*L;
end
end
x1 = a+b*(b+2*c)/(2*L);
Mmax = -(w*L^2)/8;
disp(' ');disp (['Left support Reaction' ' = 'num2str(R1) ' ' 'kN'])
disp(' ');disp (['Left support Reaction' ' = 'num2str(R2) ' ' 'kN'])
disp(' ');disp (['Maximum bending moment' ' = ' num2str(Mmax) ' ' 'kNm'])
figure %Shear Force Diagram
subplot(2,1,1);
line([x(1) x(end)],[0 0],'Color','k');
line([0 0],[0 V1],'Color','b','linewidth',1.5);
line([x(end) x(end)],[V4 0],'Color','b','linewidth',1.5);
line([0 L/2],[V1 V2],'color','b','linewidth',1.5);
line([L/2 L/2],[V2 V3],'color','b','linewidth',1.5);
line([L/2 x(end)], [V3 V4],'color','b','linewidth',1.5);
title('Shear Force Diagram (kN)','fontsize',16)
text(0,V1,num2str(V1), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
text(L/2,V2,num2str(V2), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
text(L/2,V3,num2str(V3), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
text(x(end),V4,num2str(V4), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
axis off
figure %Bending Moment Diagram
subplot(2,1,2)
line([x(1) x(end)],[0 0],'Color','k');
line([0 L/2],[0 M2],'Color','b','linewidth',1.5);
line([L/2 x(end)],[M2 0],'Color','b','linewidth',1.5);
title('Shear Force Diagram (kN)','fontsize',16)
text(L/2,+(M2/2)+2,'Lines should be curved. I would appreciate help doing so.','horizontalALignment','center','fontweight','bold','fontsize',11);
text(L/2,V2,num2str(V2), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
axis off
figure %Deflection Diagram
subplot(2,1,2)
line([x(1) x(end)],[0 0],'Color','k');
line([0 L/4],[0 D1],'Color','b','linewidth',1.5);
line([L/4 L/2],[D1 0],'Color','b','linewidth',1.5);
line([L/2 (L/4)*3],[0 D2],'Color','b','linewidth',1.5);
line([(L/4)*3 x(end)],[D2 0],'Color','b','linewidth',1.5);
title('Deflection Diagram','fontsize',16)
text(L/2,+D1/2,'Lines should be curved. I would appreciate help doing so.','horizontalALignment','center','fontweight','bold','fontsize',11);
text(L/4,D1,num2str(D1), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
text((L/4)*3,D2,num2str(D2), 'horizontalAlignment','left','fontweight','bold','fontsize',11)
axis off
Isn't the moment the integral of the shear stress?
If that's the case have a look at the matlab-function: cumtrapz.
HTH
Hi Tertius,
While I can't comment on the solution method (elasticity calcs were too long ago),it looks like all you are doing for the moment calculation is the indefinite integral of
(3/8)wL - wx
startiing from x=0 at the left end, which is
(3/8)wLx - wx^2/2
so that's the parabola.
Thanks David. So if I use (3/8)wLx - wx^2/2, how would I write the line in the code? Sorry, I am quite new to Matlab.
Tertius, if you're that new to matlab take an hour or so to get through some introduction to matlab document or video or the like, that will be worth it for you - and since you'll get a grasp of
much more general stuff that is peripheral to this direct task you'll be better prepared to take on later problems.
Also: Welcome.
good advice from Bjorn, and pay close attention to the difference between
^ and .^

Sign in to comment.

Answers (1)

Hello Tertius
In addition to Bjorn Gustavsson and David Goodmanson I would like to add following points:
  1. In case of shear force and bending moment theory, there is a way to get the equation of shear force and bending moment for each section of beam i.e. shear force = f(x) or bending moment = f(x). (Note: Bending moment is one order higher than shear force in that sectoin of beam)
  2. Once you get the analytical equation of shear force and bending moment, you can consider the position i.e. x vector and use that vector to calculate shear force and bending moment vectors for plotting purpose using the analytical equation which you got in above step.
  3. Since your objective is to plot shear force and bending moment for a beam in one figure, you must generate above step for each section separately i.e. if you have 4 sections you need 4 pairs of 'x' and 'shear force' for a beam and using ‘hold on’ command you can plot all the sections of a beam in one figure.
  4. Please refer to following documentation for understanding how to use ‘plot’ and ‘hold on’ command:https://www.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html
Kind Regards
~Pravin

Categories

Find more on General Applications in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 23 Nov 2019

Answered:

on 26 Nov 2019

Community Treasure Hunt

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

Start Hunting!