finding a maximum value in a column of a 2 dimensional matrix

조회 수: 20 (최근 30일)
Austin
Austin 2023년 12월 4일
댓글: Dyuman Joshi 2023년 12월 5일
I am new to MATLAB and I need to print a maximum value for the second column of my 2-D matrix.
maximum = max(max(variable));
Is this all I need to find that value for the variable or am I missing something more than likely

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2023년 12월 4일
No, that finds the maximum of all values of the 2D matrix.
Use indexing to provide the 2nd column of the matrix to max() -
y = magic(3)
y = 3×3
8 1 6 3 5 7 4 9 2
m = max(y(:,2))
m = 9
  댓글 수: 6
Voss
Voss 2023년 12월 4일
format long g
thrust = [0.1 500; 0.5 1000; 0.9 800] % col1: time; col2: thrust
thrust = 3×2
1.0e+00 * 0.1 500 0.5 1000 0.9 800
% [max_time, max_thrust] = max(thrust)
[max_time, max_thrust] = max(thrust,[],1)
max_time = 1×2
1.0e+00 * 0.9 1000
max_thrust = 1×2
3 2
max_time = thrust(max_thrust(2),1)
max_time =
0.5
max_thrust = thrust(max_thrust(2),2)
max_thrust =
1000

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by