Solving for theta at different time steps
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lee Quan
el 5 de Jul. de 2017
Editada: James Tursa
el 5 de Jul. de 2017
I have the following equation:
47.9618*theta + 15.9809*sin(2*theta) = 20.780136*t
Given, at time t = 0, theta = 0 radians. I want to find theta value at t = 1 second, 2 seconds, etc.
Could this be automated on matlab?
0 comentarios
Respuesta aceptada
James Tursa
el 5 de Jul. de 2017
Editada: James Tursa
el 5 de Jul. de 2017
E.g.,
>> t = 0;
>> f = @(theta) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t;
>> fzero(f,0)
ans =
0
>> t = 1;
>> f = @(theta) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t;
>> fzero(f,0)
ans =
0.2649
>> t = 2;
>> f = @(theta) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t;
>> fzero(f,0)
ans =
0.5651
3 comentarios
James Tursa
el 5 de Jul. de 2017
Editada: James Tursa
el 5 de Jul. de 2017
https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html?searchHighlight=anonymous%20function&s_tid=doc_srchtitle
Más respuestas (1)
Walter Roberson
el 5 de Jul. de 2017
Editada: Walter Roberson
el 5 de Jul. de 2017
There is no closed form solution for that. Use fzero or fsolve:
eqn = @(theta,t) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t;
for t = 1 : 5
theta0 = randn()
fzero( @(theta) eqn(theta,t), theta0)
end
0 comentarios
Ver también
Categorías
Más información sobre Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!