# Passing data as arguments in ODE45

I need to import data from file in order to describe the structure of a network. I used the following:

weights = readtable('weights192.txt');
W = weights{:,:};


Now, I need to use matrix W (its elements, its size) in the function ode below. How can I pass the matrix or just the elements I need in terms of arguments in the ode45, in order for my function to have access to it?

time = 0:0.01:5;
y0 = zeros(16,1);
[t,y] = ode45(@ode,time,y0);

function [dydt] = ode(t,y)
...
end


Alternatively, is it possible to import the matrix and its data directly in the function? Although for practical reasons of code structure, I would prefer to choose the structure of my network, outside the function.

• If you want, you may post the new part of the post as an answer to your own question and then accept it. This way, the question will not remain open. – Ertxiem - reinstate Monica Sep 18 '19 at 15:10
• I can accept my answer in 20 hours. – axel Sep 19 '19 at 16:37

[t,y] = ode45(@(t,y) ode(t,y,parameter_1,parameter_2,parameter_3,...), time, y0);