0

I want to solve a differential equation of the form dy/dt = A, where A is a vector of ones.

It shouldn't be a problem at all, yet it does not work. The code is:

t = [1 2 3 4 5 6 7 8 9 10];
var = ones(1:length(t));
y_an = 1*t;
//
function yd = f1(t,y, var)
    yd = var
endfunction
y0 = 1; t0 = 1;
//
y_m1 = ode(y0, t0, t, list(f1, var));

And it returns Error 98 at Line 10. But, if I modify the function as below:

function yd = f1(t,y, var)
    yd = var(1)
endfunction

The code runs and it returns:

y_m1  =

    1.    2.    3.    4.    5.    6.    7.    8.    9.    10. 

I am truly baffled and asking for help, ie from @LutzL. This question is also related to two others:

Odd behavior of ODE in Scilab: equation dy/dx=A is not solved properly

Scilab: How to solve an ODE where dy/dt = filter(1, ar, y1)

Fabio Capezzuoli
  • 599
  • 7
  • 23
  • Please describe the actual problem that you want to solve, this looks like a discretization or approximation done wrong. You are trying to set the derivative of a scalar to a vector. Do you want the derivative to be a function described by the function table `t,y_an`? – Lutz Lehmann Feb 23 '18 at 08:32
  • No, `y_an` is the analytical solution to the equation. The function table should be `t, var`. The actual problem I want to solve is when the derivative of `y` is a function described by an AR1 process using the Scilab function `filter()`. – Fabio Capezzuoli Feb 23 '18 at 09:00
  • Did you try posing this problem to the signal processing community http://dsp.stackexchange.com? – Lutz Lehmann Feb 23 '18 at 17:00
  • Please use math or dsp or even scientific computing to ask the question with the whole story. Use the mathjax there for formulas for increased clarity. Somehow you want to emulate numeric integration of some class of functions or even linear ODE via filters. The natural means would be back-differentiation formulas or linear multi-step methods, as they already provide the filter form. However you seem to want to fit a general filter to a selection of pairs of function and anti-derivative. Is that right so far? – Lutz Lehmann Feb 24 '18 at 07:18
  • I didn't know there was a Signal Processing community. I'll try there, it seems the right place to ask my questions. – Fabio Capezzuoli Feb 26 '18 at 01:33

0 Answers0