help with matlab syntax

hey guys im having trouble with some syntax, i know what i need the program to do but im not sure the syntax. I need the line in the for loop where it says Omega=??; I want to set Omega equal to the 'k-th' component of OMEGA, but I am not sure what is the syntax for that. Any help would be appreciated. Here is the script:
[code]function lab10ex2
omega = 2; c = 1;
OMEGA = 0:.1:3; A = zeros(size(OMEGA));
t0 = 0; y0 = 0; v0 = 0; Y0 = [y0;v0]; tf = 50; t1 = 25;
for k = 1:length(OMEGA)
Omega = ??;
param = [omega,c,Omega];
[t,Y] = ode45(@f,[t0,tf],Y0,[],param);
i = find(t>t1);
A(k) = (max(Y(i,1))-min(Y(i,1)))/2;
end
Atheory = 1/sqrt((omega^2-Omega^2)^2+(c*Omega)^2);
figure(1)
plot(t,y,'b-'); ylabel('y'); grid on;
xlabel('Omega'); ylabel('A');
%---------------------------------------------------------
function dYdt = f(t,Y,param)
y = Y(1); v = Y(2);
omega = param(1); c = param(2); Omega = param(3);
dYdt = [ v ; sin(Omega*t)-omega^2*y-c*v ];

[/code]

• Hey,

I think this is what you are looking for it acceses the element in OMEGA at the current index of the for loop here.

[code]
for k = 1:length(OMEGA)
Omega = OMEGA(k);
param = [omega,c,Omega];
[t,Y] = ode45(@f,[t0,tf],Y0,[],param);
i = find(t>t1);
A(k) = (max(Y(i,1))-min(Y(i,1)))/2;
end
[/code]

Hope this helped.