Hi!
n=[0:0.01:0.5];
f=[2:0.01:3];
for k=1:length(n)
for l=1:length(f)
beta=n(k).*Dc/Dw
omega=2e9*pi*f(l);
epsilon=3./(1+j*omega*tau);
epsilon_k(k,l)=(beta*(epsilon)+(1-beta)(epsilon_cc));
end
end
is there any advice to programm this without using for loops?
Thank you
EDIT CORRECTED PROGRAM:
Hi sorry. here is the corrected program.
n=[0:0.01:0.5];
f=[2:0.01:3];
epsilon_cc=2
for k=1:length(n)
for l=1:length(f)
beta=n(k);
omega=2e9*pi*f(l);
epsilon=3./(1+j*omega*tau);
epsilon_k(k,l)=(beta*(epsilon)+(1-beta)*(epsilon_cc))
end
end
thank you for your help!

2 Kommentare

Azzi Abdelmalek
Azzi Abdelmalek am 29 Nov. 2012
What are sizes of Dc , omega
Wayne King
Wayne King am 29 Nov. 2012
You should make your post so that people can actually execute your code. You do not give Dc, or Dw, and what is this line
epsilon_k(k,l)=(beta*(epsilon)+(1-beta)(epsilon_cc));
are you multiplying 1-beta and epsilon_cc?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 29 Nov. 2012
Bearbeitet: Jan am 29 Nov. 2012

0 Stimmen

The variable "epsilon" does not change its value inside the loop, so move its calculation out of the loop.
"beta" does not change its value inside the inner loop, so move to the outer loop.
The variables "j", "epsilon_cc", "Dc" and "Dw" are not defined in the code snippet. We cannot guess their values or if they are functions.
The expression "(1-beta)(epsilon_cc)" is not valid in Matlab. Perhapos you forgot a "*".
Please cleanup the code at first.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 29 Nov. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by