Help with basic matlab

I need to find the error between the exact solution and Euler, Runge Kuta 2 y 4.
I have the next IVP:
y' = sin(3t) - cos(t/10) + 3sen(7t) -ty
y(0)=0
I need to solve in an interval [0 20], t=0:h:20, where h = 5
But h is going to change until: abs [ (y(h)-y(h/2)/y(h) ] / n > 0.05
h = (5,5/2,5/4,...), and n = 5
The problem is not with RK2 and RK4 or how to solve the ivp, it is when I need to find the error and I need to evaluate the ivp in t=0:h:20, but i gives me an error, and it is mostly because of the -t*y part. I have been using the function eval.
Thanks alot for reading my problem

댓글 수: 3

Jan
Jan 2013년 5월 13일
The question is not clear. Please post valid Matlab syntax, such that we can copy&paste it for posting suggestions for improvements. Do not let us guess, what "3sen(7t)" explicitly means.
When you mention an error message, it is required for an answer, that you post a complete copy of it and at least the lione, which causes the error. We do not have crystal balls.
Abel
Abel 2013년 5월 13일
편집: Abel 2013년 5월 13일
Thanks for reading my question, when I use dsolve i get this ans:
dsolve('Dy = -yt + sin(3t) - cos(t.01) + 3sin(7*t)', 'y(0) = 0')
ans =
exp(-t^2/2)*int(exp(x2/2)(sin(3x) - cos(x/100) + 3sin(7x)), x = 0..t, IgnoreAnalyticConstraints)/exp(t2/2)
I would like to know how can I evaluate it in the interval t=0:h:20, if i just simply eval, matlab shows an error.
Error using sym/eval (line 11)
Error: Unexpected MATLAB expression.
I think it is because eval does't work with integrals.
Walter Roberson
Walter Roberson 2013년 5월 14일
No, it is because you did not use valid expression syntax in your strings. For example, 3t needs to be 3*t and 3sin(7*t) needs to be 3*sin(7*t)

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

답변 (0개)

카테고리

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

질문:

2013년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by