swiping row in Matrix
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ANAND ASP
el 26 de Nov. de 2020
Respondida: M.Many
el 28 de Nov. de 2020
i have this matrix (M)
M=[
1 NaN NaN 0.9 0.3;
2 14.1450 5.142 0.85 -0.1145;
3 NaN NaN NaN NaN;
4 NaN NaN 1.25 0.5;
5 18.45 9.3507 1.63 0.049;
6 NaN NaN NaN NaN;
7 17.16 0 0.7163 0.2791;
8 NaN NaN 1 0.35;
9 NaN NaN NaN NaN]
i want to reshape like this
P=[
1 1 17.16 0 0.7163 0.2791;
2 6 18.45 9.3507 1.63 0.049;
3 3 14.1450 5.142 0.85 -0.1145;
4 5 NaN NaN 1.25 0.5;
5 2 NaN NaN 0.9 0.3;
6 8 NaN NaN 1 0.35;
7 4 NaN NaN NaN NaN;
8 7 NaN NaN NaN NaN;
9 9 NaN NaN NaN NaN ]
NOTE: in first matrix 3rd coloum 7 row it has zero that why it came 1st
earlier it was 9x5 then it convert into 9x6
how can i make this?
6 comentarios
Respuesta aceptada
M.Many
el 28 de Nov. de 2020
Try this :
M= [1.0000 NaN NaN 0.9000 0.3000;
2.0000 14.1450 NaN 0.8500 -0.1145;
3.0000 NaN NaN NaN NaN;
4.0000 NaN NaN 1.2500 0.5000;
5.0000 18.4500 9.3507 1.6300 0.0490;
6.0000 NaN NaN NaN NaN;
7.0000 17.1600 0 0.7163 0.2791;
8.0000 13.1500 NaN 1.0000 NaN;
9.0000 NaN NaN NaN NaN]
[P,index] = sortrows(M,3)
P(isnan(P(:,3)),:) = sortrows(P(isnan(P(:,3)),:),2)
P(isnan(P(:,2)),:) = sortrows(P(isnan(P(:,2)),:),4)
P(isnan(P(:,4)),:) = sortrows(P(isnan(P(:,4)),:),5)
P = [ [1:9]' P]
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Numeric Types en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!