how to view struct with fields?

syms x(t) y(t) v(t) m c g s=symengine disp ('1)------------------------------------------') cond1=x(0)==0; cond2=diff(x,t)==0; conds=[cond1 cond2] dx=diff(x,t); dx2=diff(x,t,2); dv=diff(v,t); dx2=diff(x,t,2); ode=m*diff(v,t)+c*v==m*g
Sol=solve(ode,conds,dx,x)

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 2 de Jun. de 2018
You can access the fields of a struct using dot notation. For example
Sol.c
Sol.g
Also, since you are trying to solve a differential equation, use dsolve(),
Sol=dsolve(ode,conds)

8 comentarios

madhan ravi
madhan ravi el 2 de Jun. de 2018
but still I cannot find the result I wanted :/
madhan ravi
madhan ravi el 2 de Jun. de 2018
madhan ravi
madhan ravi el 2 de Jun. de 2018
Ameer Hamza
Ameer Hamza el 2 de Jun. de 2018
It is not clear which differential equation you are trying to solve. Can you clearly specify the required equations.
madhan ravi
madhan ravi el 2 de Jun. de 2018
Editada: madhan ravi el 2 de Jun. de 2018
I want to solve m(dx.^2/dt.^2)+c(dx/dt)=m*g; where m = mass, c=air resistance , g=acceleration due to gravity , x=distance travelled , x(0)=0, dx/dt(0)=0.
You can solve this equation as follow
syms x(t) m c g
disp ('1)------------------------------------------')
dx = diff(x);
cond1=x(0)==0;
cond2=dx(0)==0;
conds=[cond1 cond2];
ode = m*diff(x,2) + c*diff(x) == m*g;
Sol=dsolve(ode,conds)
Sol =
(g*m*t)/c - (g*m^2)/c^2 + (g*m^2*exp(-(c*t)/m))/c^2
madhan ravi
madhan ravi el 2 de Jun. de 2018
Thank you so much you are great
Ameer Hamza
Ameer Hamza el 2 de Jun. de 2018
You are welcome.

Iniciar sesión para comentar.

Preguntada:

el 2 de Jun. de 2018

Comentada:

el 2 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by