I'm trying to write a script that defines a function, 5*sin((2*pi).*f1.*t)+10*cos((2*pi).*f2.*t), that loops through the function for the variable t from 0 to 100 in 0.1 increments. f1 and f2 are random numbers between 0.1 and 5. I can't seem to get past the function definition when I try to run my code. I think my loop is off as well, but I can't get to a point to check it. Below is my code. in the end I need to plot it, but I know how to do that, it's just getting the function to work and populate the q array. if you could just point out the problem with the function, that would be great. I do want to write the program within a single script file.
t=0:.1:100; %generates array of time from 0 to 100 in 0.1 increments
a=0.1; %variables to generate f1 and f2
b=5; %variables to generate f1 and f2
f1=a+(b-a).*rand(1, length(t)); %creates an array of random numbers between .1 and 5
f2=a+(b-a).*rand(1, length(t)); %creats an array of random numbers between .1 and 5
q=zeros(1, length(t)); %creates space to store outputs of function for plotting
g(t, f1, f2) = @(t, f1, f2) 5*sin((2*pi).*f1.*t)+10*cos((2*pi).*f2.*t); %function for loop
for i= 1:length(t) %supposed to loop function through arrays of t, f1, and f2
q(1:i)=g(t, f1, f2); % supposed to fun the loop and store outputs in array q
end
disp(q) %shows array q to see if it works