-5
如果存在多個數組,例如存在速度,距離和時間數組。我如何找到速度的最大值以及它發生的距離和時間?在Matlab中查找最大值
如果存在多個數組,例如存在速度,距離和時間數組。我如何找到速度的最大值以及它發生的距離和時間?在Matlab中查找最大值
max
命令返回max元素的索引作爲第二個參數。
所以,如果你有三個vecotrs代表velocity
,distance
和time
同樣大小的,您可以簡單:
>> [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)