2012-03-15 78 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

回答