Pages

Monday 16 March 2015

Executing Matlab scripts on different Operating Systems

Just a quick post about making matlab scripts run on different OS.

Writing a matlab code that works on both Windows and Linux is a little challenging, especially when accessing the disk both OS use a slightly different syntax for filesystem.

One solution to this is using computer string to check the OS. Once checked you can use if condition statements to execute relevant code on each system.

The script for this is pretty straight forward and is listed below:

%compile everything
if strcmpi(computer,'PCWIN') |strcmpi(computer,'PCWIN64')
   compile_windows
else
   compile_linux
end



Sunday 15 March 2015

Estimating Pi with OpenCV

Yesterday was Pi day where the date and time specifically corresponded to the value of Pi, i.e. 3/14/15 9:26  <===> 3.1415926 . What made this day extraordinary was how different ideas and videos came out, some explaining its significance while others showing fun ways to estimate its value.

One such video caught my eye in which @thephysicsgirl and @veritasium calculated the value of Pi using Monte Carlo sampling method but with a fun twist. Instead of using random particles they decided to use random darts and a modified dart board. They explain the idea in a very simple and intuitive way in the video.