Tips & Tricks - Programing

This page will include links and files of programs or tricks I use in my projects.

all code samples are under GPLv3 License

Copyright 2008 Ofer Fridman
    This programs are free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <>.

Calling C# .Net application (DLL's) From Matlab.

posted Dec 22, 2008, 12:22 PM by Ofer Fridman   [ updated Dec 22, 2008, 1:46 PM ]

Calling Microsoft .Net Framework applications from Matlab. 

Not mine but very useful ... the samples are grate (this code is using the ability to register .net manged code as com component, if you haven't understand the last line just move to the next)

Matlab inline function from symbolic solution

posted Oct 20, 2008, 1:54 PM by Ofer Fridman

Small tip (it is not working any time).
when you  have a differential equation you want to plot (or test with values) you can use the following code.


%The result of the differential equation will be defined as function F
F=inline(char( dsolve('DN=N*(1-N/M)')));
%now we can use F as in-line function

Reading Victor Wallace (V^3) file from Matlab

posted Oct 20, 2008, 12:43 PM by Ofer Fridman

This function file usage the importdata (Matlab function) to extract the complex file structure of Wallace (xls file).


% read data
[WellTime WellMeas] = readwalacdata('blacefectivness.xls');

% plot data

Most Probable Number MPN - Matlab

posted Oct 11, 2008, 7:52 AM by Ofer Fridman

this is a translation for the Excel code from to Matlab.
this function estimates the number of bacteria in the original sample.

sample code for usage:


Dilutions = [1 1e-1 1e-2 1e-3];
Replicates = [8 8 8 8];
Positive = [8 7 4 0];
[MPN_R MPN_H MPN_L]= MPNindex(Dilutions,Replicates,Positive);

Function code attached

Costume Legend - Matlab

posted Oct 11, 2008, 7:37 AM by Ofer Fridman   [ updated Oct 11, 2008, 7:52 AM ]

This practical code sample for usage of partial or grouped legend - hence, displaing legend not for all the graphs on the plot.
By saving the handles for every line needed to have description.


%get the figure handle
%get the line handle
child_handles = findobj(h,'Type','line');
%child_handles is stord last in first index
%meening index 1 is the last line that was drown

Sample code attached.

1-5 of 5