I need ode 23 help PLEASE
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I have a very basic code about ode23 but i can not see my faults.
I must solve 3rd order ODE t^3*y''' - t^2 * y'' + 3 * t * y' - 4*y = 5*t^3 * ln(t) + 9 * t^3 for the interval t [1,4]. I must use ode23 solver and [t,y]=solver(@odefun, tspan, y0). .
exact solution is ye(t) = - t^2 + t*cos(ln(t)) + t*sin(ln(t)) + t^3 * ln(t)
The initial conditions y(1) = 0 , y'(1) = 1 and y''(1) = 3 I want to plot the exact and numerical solution for y together in same figure.
I write some code with get help from internet but i couldn't run it.
I get error.
clc
clear all
close all
function dydt = hw5(t,y)
dydt=zeros(4,1);
dydt(1)=y(2);
dydt(2)=(t*t^(3)*log(t)+9*t^3 + 4 y(1) - 3*t*y(2) - t^3*y(4)) / -t^2;
dydt(3)=y(4);
dydt(4)=(5*t^3*log(t) + 9*t^3 + t^2*y(4) - 3*t*y(3) + 4*k^2 ) / t^3;
end
% Write the main program (i.e. script) as given below.
tspan=[1 4]; IC=[0;1;3];
[t,y]=ode23(hw5, tspan, IC);
4 comentarios
Star Strider
el 27 de Mayo de 2019
First, you are missing an operator here:
dydt(2)=(t*t^(3)*log(t)+9*t^3 + 4 y(1) - 3*t*y(2) - t^3*y(4)) / -t^2;
↑
that I assume is suppossed to be multiplication.
Second, you have 4 equations and 3 initial conditions. You need an extra initial condition.
hgrlk
el 27 de Mayo de 2019
Star Strider
el 27 de Mayo de 2019
If you want t=0, you need to address it as t(1).
hgrlk
el 27 de Mayo de 2019
Respuestas (0)
La pregunta está cerrada.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!