Possibly but we will need more information about yourOriginally Posted by braddy
Thanks . this is the problem:Originally Posted by CaptainBlack
Define a general function heunstep(f,tcurr,tnext,xcurr,par) that will take one step of Heun's method to solve a system of first order initial value problems. f is the handle to a function for evaluating the first derivatives.
tcurr is the current value of the independent variable, tnext is the value of the independent variable at which the solution is sought, xcurr is a column vector containing the current values of the dependent variables, and par is a vector containing any additional parameters required in the evaluation of f. ( for example if x'=rx1+mx2+kx1^3, vector par would be par=[r,m,k])
heunstep should return a column vector containing the values of the dependent variables at tnext. Design heunstep so that if par is the empty matrix, f will be evaluated at t and x by feval(f,t,x) while if par is not empty, f is evaluated at t and x by feval(f,t,x,par).
The following function should do this. But note its untested as
I am at home at present and so don't have access to a machine
The comments contain a link to a PDF file which provides an
explanation of the theory behind the method (as if it wasn't
% function to take one step of Heun's method
% for integrating an ODE initial value problem
% Arguments: f-function handle for a function to evaluate the
% tcurr-current time
% tnext-time to step to
% xcurr-solution at tcurr
% par-row vector containing additional parameters
% for the derivative function
% Return Value: RV col vector xnext, xnext estimated solution at tnext
% xnext has the same dimensions as xcurr, and this should
% also be the same as the return value of the function that
% f is a handle for.
% Adapted from the code for: "Numerical Methods Using MATLAB", by John Mathews from Matlab Central.
% by CB 2005
You will still gave to modify or check that the code given satisfies these requirements:
I have now tested the code on my handheld under Lyme - a matlabheunstep should return a column vector containing the values of the dependent variables at tnext. Design heunstep so that if par is the empty matrix, f will be evaluated at t and x by feval(f,t,x) while if par is not empty, f is evaluated at t and x by feval(f,t,x,par).
clone, and it appears to work.
Hi it seems working . However, I will be sure when our teacher will give us a sample data.Originally Posted by braddy
Now, I need to generate the real function heun ( with n steps) using heunstep ( you helped me with) as subprogram. I am gonna try to do it.
Again thank you very much.
okay I tried to create a program using heunstep to create the general function heun for several steps but it does not work.Originally Posted by braddy
I also have problem to understand how to present the solution(T and X)
I sent The all problem is on the attachment TASK.doc so you can see precisely what it is asked.
( if you want I can send you what I tried but as I said it does not work)
Thank you very much
From the instruction sheet for this project:Originally Posted by braddy
This is an individual project. You are encouraged to discuss verbally the project with other students. You can brainstorm together solution approaches, and you can teach each other how to do things with Matlab. However, allowed collaboration ends with this verbal discussion. At no time can you copy work others have done, or have someone else do any of the work for you, or do any of the work for someone else. Everything in the Matlab files themselves must be your work, and your work alone. If you need more help, ask your proctor or instructor for assistance.
I think we should all respect these instructions.