如何在Mathematica中的列表的每个范围内找到最大值?

编程入门 行业动态 更新时间:2024-10-11 13:27:55
本文介绍了如何在Mathematica中的列表的每个范围内找到最大值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以轻松地在MATLAB中执行此操作,但是我正在尝试使用Mathematica进行操作.我有27000个元素(15分钟*每秒30次测量)的风速值列表.我想在每个2700元素(90秒)范围内找到最大值,并将其输出到矢量.这是MATLAB代码:

I can do this in MATLAB easily but I'm trying to do it Mathematica. I have a 27000 element (15 minutes*30 measurements per second) list of wind speed values. I want to find the max value in each 2700 element (90 second) range and output it to a vector. Here is the MATLAB code:

N = length(AlongWS); SegTime = 90; NSeg = (N/30)/90; Max90 = zeros(NSeg,1); Incr = N/NSeg; for i = 1:NSeg Max90(i,1) = max(AlongWS((i-1)*Incr+1:(i*Incr),1)); end

这是我在Mathematica中输入的内容:

Here is what I've typed in Mathematica:

N = Length[AlongWS] SegTime = 90 NSeg = (N/30)*60/SegTime Max90 = {} Incr = N/NSeg For[ i = 1, i < NDiv + 1, i++, maxWS[[i]] = Max[AlongWS[[(i - 1)*Incr + 1 ;; (i*Incr)]]] ]

推荐答案

尝试一下:

Max /@ Partition[AlongWS, 2700]

此操作将沿着AWS划分为长度为2700的子列表,然后在子列表中映射Max[],从而生成每个2700元素范围的最大值的列表.

This partitions AlongWS into sub-lists of length 2700, and then maps Max[] across the sub-lists, yielding a list of the maximum values of each 2700 element range.

更多推荐

如何在Mathematica中的列表的每个范围内找到最大值?

本文发布于:2023-11-29 08:50:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645922.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:范围内   最大值   如何在   列表   Mathematica

发布评论

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

>www.elefans.com

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