Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts

Thursday, October 4, 2012

Matlab fread optimization


The problem statement is to read in-phase and quadrature binary data from a file in which they are alternated:
I1
Q1
I2
Q2
...
In
Qn

each value is a 32-bit integer.

the trivial way to do it is as follow using fread function:

fid=fopen(filepath);
for k=1:n
    I(k)=fread(fid,1,'int','l');
    Q(k)=fread(fid,1,'int','l');
end

An other possibility with minimizing the access to fread function:


temp=fread(fid,IQA_sz/4,'int','l');
I(:)=temp(1:2:end);
Q(:)=temp(2:2:end);

The result is similar much the execution time is speedup by a factor 5 to 6

Tuesday, December 20, 2011

Matlab Debugger Do not Stop

Having done some Matlab development lately, I observed a strange bug. I had a main script program as follow:

clear all;
close all:

MyFunction();

... do something 
In the code debugging process, I tried to place a break point in MyFunction's code, and although the break point appears to be set in the editor GUI, the program do not stop when running!!!

After some research I figure out that the clear all command interfered with Matlab debugger and prevented the program to stop into a function. So the solution was to delete the clear all function and it the worked correctly.

It is really a shame that a 3000 CHF expensive program cannot manage the debugging process in a better way.

Sunday, February 6, 2011

clear all issue in eidors and matlab

Eidors is an open source simulation tool for Electrical Impedance Tomography (EIT). I intend to share some of my learnings with the use of this softaware.

On way to use it, is to use .m file (matlab script file) to run the desired simulation. Prior running any script EIDORS requires to run its startup.m script to setup is variables.

Personnaly I start all my scripts with the commands:
close all; %closes all open graphs
clear all; %clears all workspace variable

Doing so arises an error message from EIDORS:
??? Error using ==> eidors_obj>test_install at 87
EIDORS not correctly started. Did you do ">>run /path/to/eidors/startup"
Error in ==> eidors_obj at 69
      test_install
Error in ==> ng_mk_cyl_models at 89
fmdl = eidors_obj('get-cache', cache_obj, 'ng_mk_cyl_models' ); 
The reason is that the "clear all:" command do also clears EIDORS variables. The solution is to replace
clear all; 
by
clear;