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

4 visualizaciones (últimos 30 días)
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

Respuesta aceptada

per isakson
per isakson el 12 de Abr. de 2020
Editada: per isakson el 12 de Abr. de 2020
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 comentarios
per isakson
per isakson el 13 de Abr. de 2020
Editada: per isakson el 13 de Abr. de 2020
"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 el 17 de Abr. de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by