gpt4 book ai didi

MATLAB tic-toc 结果以分钟格式显示

转载 作者:太空宇宙 更新时间:2023-11-03 19:13:04 24 4
gpt4 key购买 nike

我在我的 Matlab 项目中的很多地方都使用了 tic-toc 函数。输出时间可以是331.5264 或1234.754 秒 等。我可以输出这种分钟格式吗?例如。 5 分 30.6 秒?谢谢!

最佳答案

您所要做的就是捕获 toc 的输出(而不是让它显示默认输出),然后使用函数 fprintf 自己创建一个输出, floor , 和 rem :

 tStart = tic;
% Do some things...
tEnd = toc(tStart);
fprintf('%d minutes and %f seconds\n', floor(tEnd/60), rem(tEnd,60));

关于MATLAB tic-toc 结果以分钟格式显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5861800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com