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

조회 수: 6 (최근 30일)
lilly lord
lilly lord 2020년 4월 12일
댓글: lilly lord 2020년 4월 17일
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