How to construct a symbolic pde that contains symbolic functions of certain variables (x & t)

1 view (last 30 days)
In the code seen below is an euler lagrange equation derivation for a cantilever beam, in the end solving for acceleration (typical system modelling stuff).
So far i have added actual functions for EIx(x) and mu(x), such as; EIx = ax+b where a and b are doubles/numbers.
Instead i would like to print the full symbolic equation, as seen below.
If i rewrite the first line as shown:
syms dw(x,t) w(x,t) w_xx(x,t) q(x,t) EIx(x,t) mu(x,t)
then the script will run. But when I write the EIx and mu as functions of x only, then errors that i do not understand occurs.
It is important in this context that matlab knows that EIx and mu is only functions of x, so that they will not be partially derived wrt. time.
Any ideas how to achieve this will be much appriciated.
%Blade params functions of x and t
syms dw(x,t) w(x,t) w_xx(x,t) q(x,t) EIx(x) mu(x)
%Lagrangian K - P + input*w
L = mu/2 * dw^2 - EIx/2 * w_xx^2 + q*w;
% img = imread('Eul_Lagr.PNG'); % Euler lagrange equation to be solved
% figure(1)
% image(img)
dL_dw = functionalDerivative(L,w); %term 1
dL_ddw = functionalDerivative(L,dw);
d_dL_ddw_dt = diff(dL_ddw,t); %term 2
dL_dw_xx = functionalDerivative(L,w_xx);
dL_dw_xx_dx1 = diff(dL_dw_xx,x);
dL_dw_xx_dx2 = diff(dL_dw_xx_dx1,x); %term 3
Eul_lagr = 0 == dL_dw - d_dL_ddw_dt + dL_dw_xx_dx2; %
w_xx1 = diff(w,x);
w_xx = diff(w_xx1,x);
Eul_lagr = subs(Eul_lagr); % Substituting wxx back
Eul_lagr = isolate(Eul_lagr, 'diff(dw(x, t), t)'); % Isolating acceleration
pretty(Eul_lagr)

Accepted Answer

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh on 1 Jul 2022
you can write it this way:
%Blade params functions of x and t
syms dw(x,t) w(x,t) w_xx(x,t) q(x,t) EIx(x) mu(x)
%Lagrangian K - P + input*w
L(x,t) = mu(x)/2 * dw(x,t)^2 - EIx(x)/2 * w_xx(x,t)^2 + q(x,t)*w(x,t);
% img = imread('Eul_Lagr.PNG'); % Euler lagrange equation to be solved
% figure(1)
% image(img)
dL_dw = functionalDerivative(L,w); %term 1
dL_ddw = functionalDerivative(L,dw);
d_dL_ddw_dt = diff(dL_ddw,t); %term 2
dL_dw_xx = functionalDerivative(L,w_xx);
dL_dw_xx_dx1 = diff(dL_dw_xx,x);
dL_dw_xx_dx2 = diff(dL_dw_xx_dx1,x); %term 3
Eul_lagr = 0 == dL_dw - d_dL_ddw_dt + dL_dw_xx_dx2; %
w_xx1 = diff(w,x);
w_xx = diff(w_xx1,x);
Eul_lagr = subs(Eul_lagr); % Substituting wxx back
Eul_lagr = isolate(Eul_lagr, 'diff(dw(x, t), t)'); % Isolating acceleration
pretty(Eul_lagr)
3 2 2 4 d d d d d 2 -- EIx(x) --- w(x, t) + --- EIx(x) --- w(x, t) - q(x, t) + EIx(x) --- w(x, t) dx 3 2 2 4 d dx dx dx dx -- dw(x, t) == - ------------------------------------------------------------------------------- dt mu(x)
or in the first case when you introduce Elx and mu as a function of x and t at the end add this:
Eul_lagr = subs(Eul_lagr,diff(mu(x, t), t),0);
Eul_lagr = subs(Eul_lagr,diff(Elx(x, t), t),0);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by