在Matlab中求Max
如果有多个数组,例如速度、距离和时间数组。我如何找到最大速度以及发生的距离和时间 命令将max元素的索引作为第二个参数返回。在Matlab中求Max,matlab,max,Matlab,Max,如果有多个数组,例如速度、距离和时间数组。我如何找到最大速度以及发生的距离和时间 命令将max元素的索引作为第二个参数返回。 因此,如果您有三个相同大小的向量,表示速度、距离和时间,您可以简单地: >> [mxv ii] = max( velocity ); % find max speed and its index >> [distance(ii), time(ii)] % distance and time corresponding to max velocity
因此,如果您有三个相同大小的向量,表示
速度
、距离
和时间
,您可以简单地:
>> [mxv ii] = max( velocity ); % find max speed and its index
>> [distance(ii), time(ii)] % distance and time corresponding to max velocity
假设
>> distance = [1:5]; % any array
>> time=[11:15];% any array
>> speed=distance./time;
>> [max_speed,index]=max(speed);
% max_speed Occurred at time(index), distance(index)