Substituting the parameters in second order differential equation

3 visualizaciones (últimos 30 días)
Ravi Joshi
Ravi Joshi el 14 de Abr. de 2015
Comentada: Ravi Joshi el 16 de Abr. de 2015
Hi,
I am deriving second order differential equation in MATLAB. I have defined a time dependent variable and then applied some derivative operations like below.
syms a b;
th = sym('th(t)'); %th is a time dependent variable
y = diff(a^2*cos(th)+(b/12)*sin(th));
thd = diff(th); %derivative of th wrt time
ybythd = diff(y,thd); %derivative of y wrt thd
p = diff(ybythd); %derivative of ybythd wrt time
These operations calculates the value of p as following-
p = diff(diff((b*cos(th(t))*diff(th(t), t))/12 - a^2*sin(th(t))*diff(th(t), t), t), diff(th(t), t))
Now, I want to plot the variable p wrt time t. Before plotting, I substituted the value of symbols a and b
newP = subs(p,[a,b],[2.1,9.5])
newP = diff((19*cos(th(t))*diff(th(t), t, t))/24 - (19*sin(th(t))*diff(th(t), t)^2)/24 - (441*cos(th(t))*diff(th(t), t)^2)/100 - (441*sin(th(t))*diff(th(t), t, t))/100, diff(th(t), t))
The variable th = sin(2*pi*t); should be substituted in order to convert the above second order differential equation into a liner equation of time t. Later on the following commands can plot p wrt time t -
syms t
thAct = sin(2*pi*t);%The function of th
time = 0.0:0.1:5.0;
for i = 1:length(time)
temp = subs(newP,th,thAct);
pVal(i)= subs(temp,t,time(i));
end
plot(time,pVal);
But the above code does not work. Somebody please tell me how to substitute the parameters in second order differential equation.
-
Thanks
Ravi
  1 comentario
Jan
Jan el 16 de Abr. de 2015
If you do not get an answer here, most likely some important information is missing. So bumping without adding new details is not successful usually.
Please explain what "does not work" mean exactly. Do you get an error message? If so, please post it completely.

Iniciar sesión para comentar.

Respuestas (2)

Ravi Joshi
Ravi Joshi el 16 de Abr. de 2015
Anybody ? is it possible in MATLAB?
- Thanks Ravi

Jan
Jan el 16 de Abr. de 2015
As far as I can see, t is not defined before "thAct = sin(2*pi*t)".
Inside the loop you use "t" as index, but it does not change during the loop:
pVal(t)= subs(temp,t,time(i));
Do you mean:
pVal(i)= subs(temp,t,time(i));
?
If you explain what "does not work" means, creating an answer would need less bold guessing.
  1 comentario
Ravi Joshi
Ravi Joshi el 16 de Abr. de 2015
Thanks Jan, It was a typing error. I modified the code. However the problem still persist. I tried to debug the problem. The expression of p seems the culprit. It has an outer diff statement. Even after substituting the values, newP has this diff statement.
Can you please look into it again?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by