Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.42 KB | None | 0 0
  1. matrix = [
  2. 0 2 4 6 8 10
  3. 1 3 5 7 9 11
  4. 12 14 16 18 20 22
  5. 13 15 17 19 21 23
  6. ];
  7.  
  8. new = new_array(matrix,4);
  9. disp (new)
  10.  
  11. function b = new_array(a,n)
  12. if n >= 0 && n <= length(a)
  13. b = a(1:n,size(a,2)-n:size(a,2));
  14.  
  15. elseif n <= 0
  16.     msg = 'Wielkosc wyekstrahowanej macierzy musi byc wieksza od 0!';
  17.     error(msg);
  18. else
  19.     msg = 'Podana wartosc przekracza wielkosc wejsciowej macierzy!';
  20.     error(msg);
  21. end
  22.  
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement