Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- clc;
- close all;
- % u,,xx=-(f/ea) on [0,L]
- % u,x(L)= R
- % u(0)=0
- % Parameters
- L= 1;
- % Parameters in force function
- A= .0001;
- E= 70e9;
- R= 1000;
- a= 1000;
- g= R/E*A;
- f= @(x) ((((-1)*(a)*(x))/E*A));
- % solve analytical solution
- u1 = dsolve(['D2y = ' char(sym(f))], ['Dy(1) = ' num2str(g)], ['y(0) ='
- num2str(0)] ,'x');
- % change symbolic function to anonymous matlab function for easier
- computing
- u = matlabFunction(u1);
- % plot the analytical solution
- n= 20;
- x = linspace(0, 1, n);
- plot(x, u(x), '-ro', 'LineWidth', 4)
- title('Analytical Solution u')
- axis([0, 1, 0, 3])
- xlabel('x')
- ylabel('u')
Add Comment
Please, Sign In to add comment