
clear
clc
format compact
format short e

% belka swobodnie podparta          
%          __________________________ q
%          __________________________      ---->x
%         /\                        /\
%          |
%          |
%          Vy

%------------------------------------------------------------
%%         d^2v/dx^2 = -M/EJ
%----------------------------------------------------------------------
 syms v(x) l q  EJ

 V= dsolve( 'D2v=(q*x^2/2-q*l*x/2)/EJ', 'x' )
%% Wynik
%% V(x)= C2 + (q*x^4 - 2*l*q*x^3 + C1*x)/(24*EJ)

 syms v(x) l q M EJ
% V= dsolve(diff(v,2)== (q*x^2/2-q*l*x/2)/EJ,v(0)==0,v(l)==0)
 V= dsolve('D2v= (q*x^2/2-q*l*x/2)/EJ', 'v(0)=0', 'v(l)=0', 'x')
%% Wynik
%%  V(x)= (q*l^3*x - 2*q*l*x^3 + q*x^4)/(24*EJ)

 M= -EJ*diff((q*l^3*x - 2*q*l*x.^3 + q*x.^4)/(24*EJ),2)
%% Wynik
%% M(x) =  (l*q*x)/2 - (q*x.^2)/2

 T= -EJ*diff((q*l^3*x - 2*q*l*x.^3 + q*x.^4)/(24*EJ),3)
%% Wynik
%% T(x)= (l*q)/2 - q*x

%----------------------------------------------------------------------
%%        d^4v/dx^4 =  q/EJ
%----------------------------------------------------------------------
 V1= dsolve('D4v= q/EJ','x')
%% Wynik
%% V1(x)= (q*x^4)/(24*EJ) + (C1*x^3)/6 + (C2*x^2)/2 + C3*x + C4

 V1= dsolve('D4v= q/EJ', 'v(0)= 0','v(l)= 0', 'D2v(0)= 0', 'D2v(l)= 0','x')
%% Wynik
%% V1(x)= (q*l^3*x)/(24*EJ) - (q*l*x^3)/(12*EJ) + (q*x^4)/(24*EJ)
 
%------------------------------------------------------------------
%------------------------------------------------------------------
%    rysunek
%% Jednostki:  kN, m
%% B25  b=30 h=50 cm 

 E= 3.0e7; J= 3.125e-3;
 l= 4; q= 3; EJ= E*J;
 V= subs(V);  V_m= matlabFunction(V);
 M= subs(M);  M_m= matlabFunction(M);
 T= subs(T);  T_m= matlabFunction(T);
 x=linspace(0,l, 20);
 vv= V_m(x);  mm= M_m(x);  tt= T_m(x);

 figure(1)
 clf
 grid on
 subplot(311)
 V_max = (5*l^4*q)/(384*EJ)
 plot(x,vv, 'm', 'LineWidth' ,2)
 xlim([-0.1 4.1])
 grid on
 axis ij
 title('v(x) [m]')

 subplot(312)
 area(x,mm, 'FaceColor', [1 212/255 103/255])
 xlim([-0.1 4.1]); ylim([-1 10])
% axis off
 grid on
 xs=l/2;
 M_max= (l*q*xs)/2 - (q*xs.^2)/2
 title('M(x) [kNm]')
 axis ij

 xs=0;
 T_max= (l*q)/2 - q*xs
 subplot(313)
 area(x,tt, 'FaceColor', [146/255 202/255 93/255])
 %xlim([-0.1 4.1]); ylim([-11 11])
 xlim([-0.1 4.1]); ylim([-7 6])
% axis off
 grid on
 title('T(x)[kN]')



