how to display how many looping are working on

2 次查看(过去 30 天)
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 个评论
Spectro
Spectro 2020-8-3
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..

请先登录,再进行评论。

回答(1 个)

SAA
SAA 2020-8-6
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by