Category:Programming language:MATLAB

From LiteratePrograms
Jump to: navigation, search

If you need help from other users with a program written in MATLAB, take a look at Category:Users:MATLAB:Experts, Category:Users:MATLAB:Knows, and possibly Category:Users:MATLAB:Some.

MATLAB is a programming language distributed by The MathWorks. The opensource language Octave is mostly compatible with MATLAB.

Please note that the name of this language is "MATLAB", unhyphenated in all-upper case, not "matlab", "MAT-LAB" or "MATHLAB".

Contents


[edit] A structured view of the articles

[edit] Tips and Tricks

A lot of tricks in MATLAB are targeted to avoid loops using linear algebra or matrices manipulations. A very good tutorial to such tricks in MATLAB array manipulation tips and tricks, by Peter J. Acklam.

[edit] Simple example: Count occurences

Example: counting occurences in an array.

<<count_elements.m>>=
function frequency_table = count_elements(vectr)
% COUNT_ELEMENTS - fast and efficient way to count different 
%  elements in an array of integers.
% 
% Example:
%  v = round(rand(300,1)*20);
%  f = count_elements(v)
%
% See also sparse 
[keys,idx,jdx]  = unique(vectr);
frequency_table = struct('keys',keys,'value',sparse(jdx,1,1));

[edit] Remove diagonal elements

Following an interesting answer on the newsgroup.

<<remove_diagonal.m>>=
m=magic(5)
r=reshape(m(~eye(size(m,2))),size(m)-[1,0])

[edit] Literate Programming

  • The section Literate programming tools (MATLAB) gives some MATLAB code to be used with LP.org, with a special OCAMAWEB Lite version in MATLAB.
  • OCAMAWEB is a free Literate Programming tool for MATLAB and some other languages.

[edit] External links

hijacker
hijacker
hijacker
hijacker

Subcategories

This category has only the following subcategory.