我可以轻松地在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中的列表的每个范围内找到最大值?
发布评论