2012-03-15 79 views
0

我正在学习python,numpy和scipy。 我不知道是否有可能在MATLAB到Python翻译这样的功能:Matlab - > scipy ode(复杂)函数翻译

function [tT, u ] = SSolve5TH(n, t, t0,tf,u_env,utop_init, utop_final,ubottom,te_idx) 
options = []; 
[tT,u] = ode23s(@SS,t,u_env,options,@B); 

function y = B(x) 
    y = zeros(n,1); 
    if x >= t(te_idx) 

     y(1,1) = utop_final; 
     y(n,1) = ubottom ; 

    else 

     y(1,1) = (x - t0)/(tf - t0) * (utop_final - utop_init) + utop_init; 
     y(n,1) = ubottom ; 
    end 
end 

function rp = SS(t,r,B) 

    global AH 
    rp = AH * r + B(t); 

    end 
end 

在这个例子中,n是数字,e.g 15;

t是时间阵列

AH = [15] XT矩阵

T0 = 0

TF = 20(例如)

u_env = [20,20,20, 20,20,20,20,20,20,20,20,20,20,20,20]

utop_init = 20

utop_final = 40 ; ubottom = 20;

te_idx = 4;

+0

这可能是可能的。你尝试了什么,你遇到了什么问题? – 2012-03-15 11:28:30

+0

问题始于苛刻的执行! – marco 2012-03-15 12:24:00

回答