Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function matrix_sort
- clc, close all;
- %%
- inpSize = 6;
- inpMtx = randi([-100 100],inpSize,inpSize);
- disp('input:');
- disp(inpMtx);
- outMtx = magicStuff(inpMtx);
- disp('sorted:');
- disp(outMtx);
- end
- function out = magicStuff(inp)
- [~,n] = size(inp);
- for i = 1:length(inp(:,1))
- for j = 1:length(inp(:,1)) - i
- if inp(j,1) > inp(j+1,1)
- x = inp(j,1);
- y = inp(j,2:n);
- inp(j,1) = inp(j+1,1);
- inp(j,2:n) = inp(j+1,2:n);
- inp(j+1,1) = x;
- inp(j+1,2:n)= y;
- end
- end
- end
- out = inp;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement