一直在寻找MatLab的替代方案...发现在Octave上工作相当困难......缺少MatLab的调试功能...遇到FreeMat ...想知道FreeMat与Octave有什么不同......它只是像QtOctave这样的Octave的图形前端(我还没有探索过)还是不止于此?它提供了哪些附加功能?什么是更好的时间利用 - 投资FreeMat或makign使用像QtOctave这样的工具(matlab不是一个选项)吗?
这是我使用后向欧拉方法以数字方式求解ODE的MATLAB/FreeMat代码.但是,结果与我的教科书结果不一致,有时甚至是荒谬的不一致.代码有什么问题?
function [x,y] = backEuler(f,xinit,yinit,xfinal,h)
%f - this is your y prime
%xinit - initial X
%yinit - initial Y
%xfinal - final X
%h - step size
n = (xfinal-xinit)/h; %Calculate steps
%Inititialize arrays...
%The first elements take xinit and yinit corespondigly, the rest fill with 0s.
x = [xinit zeros(1,n)];
y = [yinit zeros(1,n)];
%Numeric routine
for i = 1:n
x(i+1) = x(i)+h;
ynew = y(i)+h*(f(x(i),y(i)));
y(i+1) = y(i)+h*f(x(i+1),ynew);
end …Run Code Online (Sandbox Code Playgroud)