Recent Changes - Search:

Academic / Ph.D.

Research

Knowledge

Personal

Hobbies

Professional

Family

edit SideBar

MATLAB

Functions:

function [a, b] = MyFunc(x, y)

...

Array Manipulation:

  • Convert array to a vector: myarray(:);
  • Find minimum, maximum: min(myarray(:)); max(myarray(:));
  • Point by point manipulation: a = sqrt( (x .^ 2) / 2);

Vector manipulation:

First / last elements: first = v(1); last = v(end);
Normalize a vector: v = v / norm(v);
Normalize many vectors: vMag = sqrt(sum(v.ˆ2)); v = v./vMag(ones(1,size(v,1)),:);

Logic:

if (any(x(:) < 0) See if any element is less than zero

Performance:

  • Display Elapsed Time: tic; myfunc(); toc
  • Generate profiler report: profile on; profile clear; myfunc(); profile report;

Loading images:

 
colormap(gray);
i = double(imread('image.bmp', 'bmp')); % load image
i = i(:,:,1); % just load the r plane
i = i / max(i(:)); % turn image into a vector an get max

Tip Documents:

Edit - History - Print - Recent Changes - Search
Page last modified on April 22, 2007, at 10:57 AM