how to get answer from tic tok command that stays on the screen

5 次查看(过去 30 天)
Hi, I m using tic toc commamand , but answer appears in commad window for nano sec, i think and then disappears. i have attached the code. can some one tell me where is the mistake?I cannot record the values.
function .....
.....
tic
for i=0:total_Blocks-1
Plain_Text=linear_Image((i*16)+1:(i*16)+16);
Cipher_Text = cipher (Plain_Text, w, s_box, poly_mat, 1);
re_plainText = inv_cipher (Cipher_Text, w, inv_s_box, inv_poly_mat, 1);
enImage((i*16)+1:(i*16)+16)=Cipher_Text;
deImage((i*16)+1:(i*16)+16)=re_plainText;%Retrieved Plain Text
toc
end
figure,
imshow(uint8(enImage));
end

采纳的回答

per isakson
per isakson 2020-4-12
编辑:per isakson 2020-4-12
Replace
toc
by
elapsed_time = toc;
which saves the elapsed time iin the variable, elapsed_time. And add
elapsed_time
after imshow()
In response to comment
The first mistake is that tic is outside the for-loop and toc inside. I missed that because toc wasn't intended. That raises the question which elapsed time do you want to measure.
Try something like this
function elapsed_time = xyz( )
% code
elapsed_time = nan( total_Blocks, 1 );
for ii=0:total_Blocks-1
tic
Plain_Text=linear_Image((ii*16)+1:(ii*16)+16);
Cipher_Text = cipher (Plain_Text, w, s_box, poly_mat, 1);
re_plainText = inv_cipher(Cipher_Text, w, inv_s_box, inv_poly_mat, 1);
enImage((ii*16)+1:(ii*16)+16)=Cipher_Text;
deImage((ii*16)+1:(ii*16)+16)=re_plainText;%Retrieved Plain Text
elapsed_time(ii+1) = toc;
end
figure,
imshow(uint8(enImage));
end
  6 个评论
per isakson
per isakson 2020-4-13
编辑:per isakson 2020-4-13
"nothing works" is not a very useful response. What exactly doesn't work?
"[I] have tried ur function as well" How did you call my function? The output variable, elapsed_time, was it empty on return?
lilly lord
lilly lord 2020-4-17
sorry i m new in coding , later i work on ur ur comment /answer
"The first mistake is that tic is outside the for-loop and toc inside. I missed that because toc wasn't intended. That raises the question which elapsed time do you want to measure.'
and i have solved the problem. thank you so much for ur help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by