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?

 채택된 답변

James Tursa
James Tursa 2017년 7월 5일
편집: James Tursa 2017년 7월 5일

1 개 추천

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

Lee Quan
Lee Quan 2017년 7월 5일
편집: Lee Quan 2017년 7월 5일
So for getting results from t = 0 to 10 seconds at once, I could do this:
for t=0:10
f = @(theta)47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t;
fzero(f,0)
end
Awesome! Thanks James!
Lee Quan
Lee Quan 2017년 7월 5일
Could you point me to some resources where the '@' notation is used so that I can familiarize myself with it? The @ part is something I can't find in matlab documentation online.
James Tursa
James Tursa 2017년 7월 5일
편집: James Tursa 2017년 7월 5일
https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html?searchHighlight=anonymous%20function&s_tid=doc_srchtitle

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 7월 5일
편집: Walter Roberson 2017년 7월 5일

1 개 추천

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

카테고리

도움말 센터File Exchange에서 Functions에 대해 자세히 알아보기

태그

질문:

2017년 7월 5일

편집:

2017년 7월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by