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

5 vues (au cours des 30 derniers jours)
lilly lord
lilly lord le 12 Avr 2020
Commenté : lilly lord le 17 Avr 2020
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

Réponse acceptée

per isakson
per isakson le 12 Avr 2020
Modifié(e) : per isakson le 12 Avr 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 commentaires
per isakson
per isakson le 13 Avr 2020
Modifié(e) : per isakson le 13 Avr 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 le 17 Avr 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by