From: Kamaraju N on
Dear all,
I have a equation that goes like this.....
d^2/dt^2[x] + f(t) x - gamma * d/dt [x] where f(t) is a function of t. I have a numerical form of f(t), but no analytical form, so i want to pass this whole vector into my function....but I am able to pass only a single value...My program is as follows,

Main.m
clear all
close all;
clc;
s1 = input('Input File name without any *.txt extention :','s');
input_file_name = [s1 '.txt'];
Data=load(input_file_name); % column vector

time = Data(:,1)'; % Convert to row vecor
init = [0,0.5*2*pi]; % Initial condition
f =1.42E27*Data(:,2); % f(t) -- only numerical form is available

[t,y]=ode45(@eqn,time,init,[],f); % If u remove f from here and write this as %exp(-t/2E-12) inside the fun eqn.m, then, it works
plot(t,y(:,1))

eqn.m
function rk = eqn(t,y,f)
gamma= 2*pi*0.1E12;
rk = [y(2); - (f y(1)) -gamma*y(2)];

Could anyone help me out to solve this problem...

with best regards
kamaraju