Azzera filtri
Azzera filtri

How to select the column of matrix?

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 16 Mar 2022
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
.

Più risposte (0)

Categorie

Scopri di più su Linear Algebra in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by