How can I plot a symbolic time-domain function with long expressions?

4 views (last 30 days)
Greetings,
I'm writing a code to achieve gust response of a 2D airfoil section. I used "Symbolic" in order to solve the time-domain set of equations by applying Laplace transformation, Cramer (with Wronskian) and Inverse Laplace transformation. I successfully plot the 1-DOF gust response with using fplot. When I tried for 2-DOF, the graph goes blank. In addition, for both of the plotting process, my computer lagged. I want to see if the 2-DOF time-domain function is obtained or not, and I see that it is obtained but it is a long function:
I thought, maybe the graph is not plotted because of my computer performance (either I didn't update my computer for a while or I didn't update MATLAB for a while). I tried to simpify 2-DOF function, so that I can plot the graph. With help of "vpa", I find a simplified function. When I plotted both of the simplied function and 1-DOF function, I achieve this graph:
I thought that, I achieve this result because 1-DOF is already a simplified version of 2-DOF, and I probably obtained the 2DOF time-domain function correctly. The reference graph is:
Can you help me to plot the 2-DOF time-domain function and speed up my MATLAB code (both for this case and in general)? My MATLAB code is shown below:
clc;clear;
syms s
Mu= 43.98;
Cl= 2*pi;
A= 0.0375 ;
V= 1;
r= 0.5;
r2= r*r;
x= 0;
a= 0;
Sigma= V*sqrt(A);
w0=1;
Kussner=1/s-0.5/(s+0.13)-0.5/(s+1);
Wagner=1/s-0.165/(s+0.0455)-0.335/(s+0.3);
Wgust=w0/s; % for sharp edge gust
% E=Cl*Wgust*s*Kussner/(Mu*V);
% F=(1+Cl*Wagner/Mu+Cl/(2*Mu))*s*s+A;
%
% X=E/F;
%
% Xi_1DOF=ilaplace(X);
K1=s*s+A+Cl*s*s/(2*Mu)+Cl*s*s*Wagner/Mu;
K2=x*s*s/r2-Cl*a*s*s/(2*r2*Mu)-Cl*Wagner*s*s*(1/2+a)/(r2*Mu);
K3=x*s*s+Cl*(s-a*s*s)/(2*Mu)+Cl*(s+(1/2-a)*s*s)*Wagner/Mu;
K4=s*s+1/(V*V)-Cl*(-(1/8+a*a)*s*s-(1/2-a)*s)/(2*r2*Mu)-Cl*(1/2+a)*((1/2-a)*s*s+s)*Wagner/(r2*Mu);
K5=Cl*Wgust*s*Kussner/(Mu*V);
K6=Cl*(1/2+a)*Wgust*s*Kussner/(r2*Mu*V);
X2=(K5*K4-K6*K2)/(K1*K4-K3*K2);
Xi_2DOF=ilaplace(X2);
% Xi_simplified = vpa(Xi_2DOF);
%
% Xi_Diff = Xi_simplified - Xi_1DOF;
fplot(Xi_2DOF,[0,200])
% subplot(1,1,1)
% fplot(Xi_1DOF,[0,200])
% % fplot(Xi_1DOF,[0,200],'Linewidth',2)
%
% hold on
%
% fplot(Xi_simplified,[0,200],'--or')
% fplot(Xi_Diff,[0,200],'-.*c')
% legend('\xi_{1-DOF}','\xi_{Simplified}=vpa(\xi_{2-DOF})','\xi_{Diff }= \xi_{Simplified} - \xi_{1-DOF}')
%
% hold off

Accepted Answer

Walter Roberson
Walter Roberson on 26 Dec 2020
fplot can do a lot of work to try to find singularities. This can make it very slow on complicated functions.
For plotting purposes it is often better to use matlabFunction to create a function handle and evaluate the handle on a vector of x values and use plot(). You will not get singularities marked on it but you probably do not care about that at the moment.
  1 Comment
Emre Kara
Emre Kara on 27 Dec 2020
I create a matrice of time and get matrices of results from time-domain function.
for i=0:1:200
t(i+1)=i;
Xi1(i+1)=Xi_1DOF(i);
Xi2(i+1)=Xi_2DOF(i);
end
The graph is plotted incorrectly. Then, I checked my formulation and update my code via switching K2 and K3 (which probably means "vpa" is not simplifying the complicated functions, only removing insignificant digits to speed up the code). Finally, I plotted the graph accurately.
Thank you so much for your help.

Sign in to comment.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!