Add value in a matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi, I need to add a row of values to an array, taking into account the last row of my array (once sorted) I want the next row to show a number starting at 1 that is related to the previous row. Here is an example to try to explain it better
% First matrix
Z = [255 1 0 255 255 255 1
30 51 51 30 29 29 21
49 51 52 48 51 52 48
-5 4 4 -5 -4 -4 4];
% Orderly matrix in the 4th row
ZORD = [255 255 255 255 1 0 1
30 30 29 29 21 21 21
49 48 51 52 51 52 48
-5 -5 -4 -4 4 4 4];
% So far I know how to do it, but this is what I put in now is what
% I only know how to do with a for-loop but for my data size it is not very operational.
ZFIN = [255,255,255,255,1,0,1;
30,30,29,29,21,21,21;
49,48,51,52,51,52,48;
-5,-5,-4,-4,4,4,4;
1 1 2 2 3 3 3]
If someone knows how to do the last step I would be very grateful, thank you very much
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!