loop and loglog problem

2 views (last 30 days)
gulcin
gulcin on 14 Apr 2013
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;

Accepted Answer

Image Analyst
Image Analyst on 14 Apr 2013
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)???
  14 Comments
gulcin
gulcin on 15 Apr 2013
i,j,k represents the numbers 0.01,0.02,....,50. Even if I put indexes to A,B,C it doesn't run.
gulcin
gulcin on 15 Apr 2013
I am so stucked please help!

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!