Tuesday, December 25, 2007

Notes Matlab

Notes Matlab
============

Contents
=========
Help
MEX - C


MEX - C
========

A list of mx-MEX functions is found in:
Help -> MATLAB -> C and Fortran Functions

Mex interface in C code:
******************
void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
/* more C code ... */
******************



Help:
=====
>matlab -help

Setup Matlab's path - save the following into startup.m
*********************
% Add my test directory as the first entry
% on MATLAB's search path

path('/import/george/Applied/chee/programs/RKohn/SallyW',path)
*********************

To Run Matlab m-file, just type the name WITHOUT the ".m"
eg to run Hello.m, type "Hello"


Running Matlab:
1. GUI environment: /usr/local/matlab/bin/matlab
2. NO GUI: /usr/local/matlab/bin/matlabl -nojvm



*********************
RESHAPE

>> crshp(:,:,1)=[1,2,3,4;5,6,7,8;9,10,11,12]
>> crshp(:,:,2)=[13,14,15,16;17,18,19,20;21,22,23,24]
crshp(:,:,1) =
1 2 3 4
5 6 7 8
9 10 11 12
crshp(:,:,2) =
13 14 15 16
17 18 19 20
21 22 23 24

>> reshape(crshp(:,:,1), 12, 1)
ans =
1
5
9
2
6
10
3
7
11
4
8
12