Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save shaybensasson/465db066eb6b226cdc8d to your computer and use it in GitHub Desktop.

Select an option

Save shaybensasson/465db066eb6b226cdc8d to your computer and use it in GitHub Desktop.
matrix|array|vector manipulation
%acessing and slicing
a=[1 2;3 4]
%{
a =
1 2
3 4
%}
%accessing a 2d array using 1d array index
a(1,2) %2
%% use ':' for don't care values
a(:,2)
%{
ans =
2
4
%}
a(1,:)
%{
ans =
1 2
%}
%'end' keyword
a(2:end)
%{
ans =
3 2 4
%}
%% values rotation
i = eye(3);
i = rot90(i) %mirror
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment