필터 지우기
필터 지우기

Magnitude, row and column in a Matrix

조회 수: 3 (최근 30일)
Ricardo Gutierrez
Ricardo Gutierrez 2020년 1월 22일
댓글: Ricardo Gutierrez 2020년 1월 23일
Good Morning.
I have a matrix A
A = [87.97 87.97 17.97
95.22 87.96 91.26
75.50 75.50 75.50
78.13 64.89 78.90];
What instructions should I do to get
Minimum value per column
The line and column of that value
The result would be:
magnitude 75.50 64.89 17.97
row 3 4 1
column 1 2 3
Greetings and thanks

채택된 답변

Star Strider
Star Strider 2020년 1월 22일
Try this:
A = [87.97 87.97 17.97
95.22 87.96 91.26
75.50 75.50 75.50
78.13 64.89 78.90];
[MaxA,MaxRow] = max(A)
[MinA,MinRow] = min(A)
producing:
MaxA =
95.2200 87.9700 91.2600
MaxRow =
2 1 2
MinA =
75.5000 64.8900 17.9700
MinRow =
3 4 1
  댓글 수: 6
Ricardo Gutierrez
Ricardo Gutierrez 2020년 1월 23일
This is the code I have, with your suggestions.
______________________________________________
clc; clear; close all; format short;
A=[ 87.97 87.97 17.97
95.22 87.96 91.26
75.50 75.50 75.50
78.13 64.89 78.90];
[MinA,MinRow] = min(A)
[RowMin,ColMin] = find(A == min(A(:)))
__________________________________________________
This is the results show in the Command Window
______________________________________________
MinA =
75.5000 64.8900 17.9700
MinRow =
3 4 1
RowMin =
1
ColMin =
3
ColMin =
3
>>
___________________________________________
As we see it does not show me the columns.
It shows me only one
Already the minimum values and the rows are resolved, only the columns are missing.
Thanks for your help
Star Strider
Star Strider 2020년 1월 23일
It actually shows everything you want it to show.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2020년 1월 22일
Use the two output form of min(). The second output will be the appropriate row numbers.
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 1월 23일
The column number is 1:number of columns
Ricardo Gutierrez
Ricardo Gutierrez 2020년 1월 23일
Thanks

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

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by