Gabriel Scalosub

Department of Communication Systems Engineering
Ben-Gurion University of the Negev
Alon Building for High-Tech (Building 37), Room 414
P.O.B. 653 Beer-Sheva 8410501 Israel
Phone: +972-8-6477230
Fax: +972-8-6472883
Email: press here

"I hear and I forget. I see and I remember. I do and I understand."
Confucius (551 BC - 479 BC)


Matlab Tips

Contents:

Run Matlab in the Background

Unix C-shell Script

Save the following script in a file, say matlab-in-background, and make it executable:
#!/bin/csh -f
unsetenv DISPLAY
nohup matlab < $1 > $2 &

Usage

Run the command:
matlab-in-background [input] [output]
where [input] is the script file to run by matlab, and [output] is the file to which the output should be dumped into.

Misc Tips

functions on a field in an array of structures

Assume a structure, e.g., packet, with the fields
packet.arrivalTime
packet.departureTime
Assume an array of structures, e.g., traffic, where for every i, traffic(i) is a packet. To compute a function of one of the fields, over all structures in the array, use the cat() function. E.g., in order to compute the maximum arrival time of a packet in the traffic, use:
max(cat(1,traffic.arrivalTime))
This concatenates the values of the field arrivalTime of all entries in the traffic structure array into a 1-dimensional matrix, thus enabling running the max() function on the array of reals.

plotting a function parameterically, quickly

To plot the function f(x)=x/(1+x) in the domain [0,1], use
f = @(x) x./(1+x);
ezplot(f,[0,1]);
This makes use of the Symbolic Toolbox (see online documentation for further info).