Making a Function for matrix

조회 수: 2 (최근 30일)
Manosh Chandra Haldar
Manosh Chandra Haldar 2020년 2월 24일
댓글: Manosh Chandra Haldar 2020년 2월 27일
How can I write a function that takes a matrix input argument, calculates the difference bwtween maximum and mimuim valued elements in each row and gives a row vector as its output. see the following example
A = [1:4;5:8;9:12];
[x y] = minimax (A)
x = 3 3 3
y = 11

답변 (1개)

KSSV
KSSV 2020년 2월 24일
편집: KSSV 2020년 2월 24일
iwant = (max(A,[],2)-min(A,[],2))'

태그

Community Treasure Hunt

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

Start Hunting!

Translated by