0
votes

I'm learning python, numpy and scipy. I'm wonder if it is possible translate this kind of functions in matlab to python:

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

In this example, n is number, e.g 15;

t is the time array

AH = [15]x t matrix

t0 = 0

tf = 20 (e.g)

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;

1
This is probably possible. What did you try and what problems did you encounter? - Fred Foo
Problem starts with ode stiff implementation ! - marco

1 Answers