필터 지우기
필터 지우기

How to select the column of matrix?

조회 수: 4 (최근 30일)
Chetan Fadnis
Chetan Fadnis 2022년 3월 16일
댓글: Star Strider 2022년 3월 16일
I have a 10*5 matrix, say A.
I calculate vecnorm, B=vecnorm(A), which gives me values of norm-2 of each column, of order (1*5)
Now I have to select that particular column which highest value of vecnorm. Final matrix will be thus 10*1.

채택된 답변

Star Strider
Star Strider 2022년 3월 16일
Try this —
M = randn(10,5) % Create Matrix
M = 10×5
-2.4914 -0.9224 0.4424 0.0403 0.2552 0.0438 1.7929 1.4369 -0.1068 0.4421 -1.0425 -1.6377 -0.0228 -0.7257 0.2237 -2.4847 0.1353 1.3723 -0.3405 -0.4301 1.1223 0.2980 -0.6060 0.6482 -0.8294 -0.3723 0.1228 0.0323 -1.3601 -2.4858 -0.7934 -1.5298 1.0757 -0.4600 -1.3015 -1.1643 -0.5968 -0.2552 0.1067 0.2075 -0.9318 3.4273 1.2028 1.4698 -0.7706 0.9572 -1.9723 0.5205 -0.1401 -0.0858
Mv = vecnorm(M)
Mv = 1×5
4.3171 5.0202 2.7300 2.3084 3.1146
[mxMv,col] = max(Mv)
mxMv = 5.0202
col = 2
Desired_Output = M(:,col)
Desired_Output = 10×1
-0.9224 1.7929 -1.6377 0.1353 0.2980 0.1228 -1.5298 -0.5968 3.4273 -1.9723
.
  댓글 수: 2
Chetan Fadnis
Chetan Fadnis 2022년 3월 16일
thanks.
Star Strider
Star Strider 2022년 3월 16일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by