I have an ode function which is of the form:(adsbygoogle = window.adsbygoogle || []).push({});

function [output]=Fun[input1,input2,input3]

which is solving a set of non-linear differential equations. input1 and 3 are fixed but input2 is a variable. Say:

input1=3; % a constant

input3=20;

input2=[2 4 6 8];

function Fun is being called in an m.file called main. The ode is being solved 20 times (input3 defines number of repetition). I want Fun to use a different element of vector input2 each time and repeat this process again and again until the number of input3. That is:

first time solving : input2=2;

second time solving: input2=4;

.

.

.

fifth time solving: input5=2 again

and this process must repeat until Fun reaches input3=20

Any suggestions are welcome.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How to pass a variable input into a function in matlab?

**Physics Forums | Science Articles, Homework Help, Discussion**