MATLAB: Loop and loglog problem

loglogloopplot

Hello, I wrote a code, but it didn't run. I think loops are wrong.I want to solve those functions and then to plot them in loglog graphs.What are my mistakes? Is there anyone who can help me?Please help.
%Source Function
fc=0.4;
Ohm=20;
x=0.01:0.01:50;
for i=1,5000;
for j=1,5000;
for k=1,5000;
x=f(i);
x=f(j);
x=f(k);
S(i)=Ohm/(1+((f(i)\fc)^2));
S(j)=(Ohm*((2*pi*fc)^2))/(1+((fc/f(j))^2)*(2*pi*f(j)));
S(k)=(Ohm*((2*pi*fc)^2))/(1+((fc/f(k))^2));
end
end
end
loglog(S(i));
loglog(S(j));
loglog(S(k));
grid on;

Best Answer

First of all, this is incorrect syntax:
for i=1,5000;
You need to do it like this:
for i=1:5000 % No comma (colon instead of comma) , no semicolon.
Next, your S gets overwritten for i, j, and k. Was S supposed to be a 3D array S(i, j, k)???
Related Question