Could anyone help me to solve the issue for the following code

Code:
Bmax=2000;
noise=1e-5;
p_fix=0.05;
for it=1:2
G =[4.2638 4.2227 4.2658 4.4176 4.6851 5.0623
2.2943 2.3644 2.4166 2.4525 2.4750 2.4880
0.0637 0.0599 0.0563 0.0533 0.0509 0.0494
0.0427 0.0429 0.0431 0.0432 0.0434 0.0435];
C =[4.2638 0 0 0 0 5.0623
0 0 0 0 2.4750 0
0 0 0.0563 0 0 0
0 0.0429 0 0.0432 0 0]
t=4;
r=6;
throughput =((Bmax.*log(1+((p_fix).*C))./ noise))
overall_throughput = sum(sum(throughput))
output(t,r)=overall_throughput
output_it(t,r,it)=output(t,r)
end
If i run the following code it executes.
But for every iterations the output remains the same value.
Could anyone help me how to get different values of output for every iteration.

2 Comments

Everything in there is a constant. You can move it all out of the loop. The first thing to look for to spot this is not using your loop variable anywhere but an assignment index.
At least one value somewhere needs to change inside the loop, either randomly or based on the loop iteration.
Also, why all the intermediate variables?
overall_throughput = sum(sum(throughput))
output(t,r)=overall_throughput
output_it(t,r,it)=output(t,r)
Can be
output_it(t,r,it)=sum(sum(throughput))

Answers (0)

This question is closed.

Tags

Asked:

on 4 Apr 2018

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!