Wrong answer for sine function

조회 수: 1 (최근 30일)
Ellen Brown
Ellen Brown 2019년 11월 17일
댓글: Star Strider 2019년 11월 17일
I am trying to create a function to evaluate sine at different values of t
function F = rforce(t)
F = 0.3 + 0.2.*sin(2.*pi.*t/365 - pi/2);
end
but this gives the incorrect answer when ran in matlab
  댓글 수: 2
Star Strider
Star Strider 2019년 11월 17일
It would appear that the units of ‘t’ are days, so ‘F’ would be with respect to years (or fractions of years).
What result do you want?
Ellen Brown
Ellen Brown 2019년 11월 17일
I want F in respect to days, how would I do this?

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

채택된 답변

Star Strider
Star Strider 2019년 11월 17일
Define ‘t’ in terms of days (or fractions of days).
Try this:
rforce = @(t) 0.3 + 0.2.*sin(2.*pi.*t/365 - pi/2);
tdays = 1:0.25:365.25; % One Year in 6-Hour Increments
figure
plot(tdays, rforce(tdays))
grid
xlabel('Days')
ylabel('r Force')
xlim([min(tdays) max(tdays)])
  댓글 수: 2
Ellen Brown
Ellen Brown 2019년 11월 17일
thank you!
Star Strider
Star Strider 2019년 11월 17일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by