how to display how many looping are working on

1 view (last 30 days)
Raja Zufar
Raja Zufar on 2 Aug 2020
Answered: SAA on 6 Aug 2020
Hallo i have this part of code,
I want to see how many TTI looping are working on in the "command window" bar. because I don't know how long this program will run and how many repetitions have happened
TTI=1000;
for x=1:TTI
[r_TxPU_TTI(:,x), r_TxPU_RxPU_TTI(:,x), r_TxSU_TTI(:,x),r_TxSU_RxSU_TTI(:,x), r_TxSU_RxPU_TTI(:,((jumlah_SU*x) -var):(x*jumlah_SU)),r_TxPU_RxSU_TTI(:,((jumlah_SU*x)-var):(x*jumlah_SU))] = generate(radius_cell, radius_Tx, teta_cell, jumlah_PU, jumlah_SU);
end
Thank you :))
  1 Comment
Spectro
Spectro on 3 Aug 2020
Simply add disp(x) to the body of the cycle like below:
TTI=1000;
for x=1:TTI
[r_TxPU_TTI(:,x), r_TxPU_RxPU_TTI(:,x), r_TxSU_TTI(:,x),r_TxSU_RxSU_TTI(:,x), r_TxSU_RxPU_TTI(:,((jumlah_SU*x) -var):(x*jumlah_SU)),r_TxPU_RxSU_TTI(:,((jumlah_SU*x)-var):(x*jumlah_SU))] = generate(radius_cell, radius_Tx, teta_cell, jumlah_PU, jumlah_SU);
disp(x)
end
or look up fprintf(), but i think disp() should do if your goal is just to know in what iteration you are..

Sign in to comment.

Answers (1)

SAA
SAA on 6 Aug 2020
you can just type x in yout loop and see what it is
TTI=1000;
for x=1:TTI
[r_TxPU_TTI(:,x), r_TxPU_RxPU_TTI(:,x), r_TxSU_TTI(:,x),r_TxSU_RxSU_TTI(:,x), r_TxSU_RxPU_TTI(:,((jumlah_SU*x) -var):(x*jumlah_SU)),r_TxPU_RxSU_TTI(:,((jumlah_SU*x)-var):(x*jumlah_SU))] = generate(radius_cell, radius_Tx, teta_cell, jumlah_PU, jumlah_SU);
x
end
or as Spectro suggeste use disp or frprintf, this one is better
TTI=1000;
for x=1:TTI
[r_TxPU_TTI(:,x), r_TxPU_RxPU_TTI(:,x), r_TxSU_TTI(:,x),r_TxSU_RxSU_TTI(:,x), r_TxSU_RxPU_TTI(:,((jumlah_SU*x) -var):(x*jumlah_SU)),r_TxPU_RxSU_TTI(:,((jumlah_SU*x)-var):(x*jumlah_SU))] = generate(radius_cell, radius_Tx, teta_cell, jumlah_PU, jumlah_SU);
fprintf('Iteration #%d\n', x);
end

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!