Wednesday, February 27, 2008

open dialog to "open file" in matlab

Hi people, today there is a very interesting post on a matlab central's blog. it describes how you can open a dialog to choose a file from the command line, and use it in some scripts.

the video is here.


Thursday, February 21, 2008

calculate min/max in matlab excluding the zeros

the problem is how to calculate the minimum of a vector excluding the zeros?
here is an example how to do that:

min(myVector(myVector > 0))

about logical indexing

Today, M-Lint was telling me that "logical indexing is usually faster than FIND".

I didn't knew what logical indexing means. a short google search and i found this out:

if you want to perform the following operation:

KdP(find( (dP> 1000) & (dP <= 2000) )) = 2;

you can optimize it just by omitting the find command just like this:
KdP( (dP> 1000) & (dP <= 2000) ) = 2;

. Matlab is just capable to handle the "logical indexing" which means the indexes of the vector that match the conditions.

Tuesday, February 19, 2008

how to turn a matrix into a single vector with matlab

hi, if you are trying to transform a matrix into a single vector you sould't use if's.

there is a very easy way to do that.
if your matrix a = [1 2 3; 4 5 6], the command b=a(:) will generate a matrix b that looks like this: [1 4 2 5 3 6]'

Tuesday, February 12, 2008

use profiler to improve code

there is a very cool application in matlab to help you improve the code. it is called "profiler".
let me give you an example. If you have a script named "name_of_script.m", you can enter the following commands to check it:

profile on, name_of_script, profreport('name_of_script')

at the end, you'll get a new windows, where you can find which section of the script is the bottleneck.

happy coding!

improving matlab code to run faster

improve matlab code to run faster... that's the question. i found a very cool document on the web. you can find it here.

List of Matlab tutorials and Howtos

Great list of matlab tutorials and howtos.

you can find it here

Saturday, February 9, 2008

function in matlab to convert 1/4-h vectors to 1-h vector

sometime i have to handle with large data vectors, which are time measurements. One value each 15 Min.

For the analysis, i can use 1 value per hour. to convert the vectors i use the following function:

function DATout = convert_15min_1h(DATin)
for i=1:1:size_1h

Friday, February 8, 2008

Zeilenabstand in LaTeX

um in LaTeX den Zeilenabstand zu ändern, z.b. von 1,5 auf 1,0 oder sogar 1,25, benutzt man diesen Kommando im prämble: