Skip to content

Instantly share code, notes, and snippets.

@Nimster
Created May 6, 2012 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nimster/2624523 to your computer and use it in GitHub Desktop.
Save Nimster/2624523 to your computer and use it in GitHub Desktop.
Quick reference to some common Matlab idioms/capabilities - mainly to serve as a reminder for me
[I, J] = find(A > 0) % Col-order search
[J, I] = find(A' > 0) % Row-order (non-zero) search
arrayfun(@(x) length(x.field)>0, some_struct_array) % Apply length to 'field' in each element of a struct array
a_struct = struct('field1', value1, 'field2', value2) % Create a struct ("object")
list = [list 1] % add element to a vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment