Piecewise parameter in matlab

87 Views Asked by At

I'm trying to define this paramater in matlab for my system of differential equations code but i don't know how to work this out:

enter image description here

What i tried:

syms f f1 
j = input('Enter value of j: ');
T1 = 4.5;
T2 = 0.83;
if ((t >= T1+j && t <= T2+j))
    f = 1;
else
    f = 0;
end

but i don't know how to define the variable t.

1

There are 1 best solutions below

0
On

You can define an anonymous function:

delta = @(t) any(arrayfun(@(j) (9/12+j <= t)*(t <= 10/12+j), 0:8))