Substituting the parameters in second order differential equation
Mostrar comentarios más antiguos
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
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.
Respuestas (2)
Ravi Joshi
el 16 de Abr. de 2015
0 votos
1 comentario
Jan
el 16 de Abr. de 2015
This is not an answer.
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
el 16 de Abr. de 2015
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!