Matlab日期向量(Matlab Date Vector)

编程入门 行业动态 更新时间:2024-10-14 12:23:08
Matlab日期向量(Matlab Date Vector)

我有一个数组A,其中包含hhmmss格式的时间信息。 最后,我想通过指示经过的时间(以秒为单位,从第一次开始)来规范化此数组。

A = [150213 150013 145813 145613 145413 145313 145213 145113 145013 144943 144913 144843 144833 144823 144813 144803 144753 144743 144741 144739 144737 144735 144733 144731 144729 144727 144725 144723 144721 144719]

所以,最后数组应该是:

A_updated = [894 774 654 534 414 354 294 234 174 144 114 84 74 64 54 44 34 24 22 20 18 16 14 12 10 8 6 4 2 0]

什么是最快的'Matlab方式'继续这个? 非常感谢你的想法。

I have an array A with time information in the format hhmmss. Ultimately, I would like to normalize this array by indicating the elapsed time (in seconds, starting from the first time).

A = [ 150213 150013 145813 145613 145413 145313 145213 145113 145013 144943 144913 144843 144833 144823 144813 144803 144753 144743 144741 144739 144737 144735 144733 144731 144729 144727 144725 144723 144721 144719]

So, in the end the array should be :

A_updated = [894 774 654 534 414 354 294 234 174 144 114 84 74 64 54 44 34 24 22 20 18 16 14 12 10 8 6 4 2 0 ]

What would be the quickest 'Matlab way' to proceed with this? Many thanks in advance for your ideas.

最满意答案

我暂时没有使用过Matlab,所以原谅语法错误,我现在还没有它,但是这就是我想要的。 基本上,将所有内容转换为秒,然后减去最后一个元素。

At = uint32(A); A_updated = mod(At,100); At = floor(At ./ 100); A_updated = A_updated + mod(At,100) * 60; At = floor(At ./ 100); A_updated = A_updated + At * 3600; A_updated = A_updated - A_updated(end);

I haven't used Matlab in a while, so forgive the syntax mistakes, and I don't have it available right now, but here's what I would try. Basically, convert everything to seconds then subtract the last element.

At = uint32(A); A_updated = mod(At,100); At = floor(At ./ 100); A_updated = A_updated + mod(At,100) * 60; At = floor(At ./ 100); A_updated = A_updated + At * 3600; A_updated = A_updated - A_updated(end);

更多推荐

本文发布于:2023-08-01 21:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1365828.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:向量   日期   Matlab   Date   Vector

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!