May 9, 2012 0

first version of matlab struct iterator

By in matlab

matlab script to iterate through a struct and extract names and values

function [ names values ] = structIterator( struct, prependName,delimiter, names, values )
%STRUCTITERATOR This utility function iterates through all fields in struct.
%If fields doesn’t contain a struct it construct and stores iterated and concatenated field names separated by delimiter in the vector
%names and the corresponsing values in values
% This function can be called as structIterator(struct) without further
% arguments
% Version 0.1
% Copyright
% Thomas Mosgaard Giselsson
if nargin names = {};
values = [];
end
if nargin prependName=”;
end
if nargin delimiter = ”;
end
if isstruct(struct)
fieldNames = fieldnames(struct);
for name=fieldNames’
if isempty(prependName)
prependNameS = name{:};
else
prependNameS = [prependName delimiter name{:}];
end
if isstruct(struct.(name{:}))
[names values] = structIterator(struct.(name{:}),prependNameS,delimiter,names,values);
else
names=[names; prependNameS];
values = [values; struct.(name{:})];
end
end
end

April 27, 2012 0

note on using checkinstall to construct deb for poppler

By in checkinstall, poppler

the command that successfully created a deb file was

checkinstall –fstrans=no –install=no -D

Should maybe be called with sudo

April 26, 2012 0

monitor system events on ubuntu

By in linux, ubuntu

to monitor system events such as connecting/disconnecting usb devices do

tail -f /var/log/syslog

March 23, 2012 0

RQ decomposition in matlab

By in matlab

Source: http://www.mathworks.com/matlabcentral/newsreader/view_thread/237007


function [R Q]=rq(A)
% function [R Q]=rq(A)
% A [m x n] with m R=flipud(R.');
R(:,1:m)=R(:,m:-1:1);
Q=Q.';
Q(1:m,:)=Q(m:-1:1,:);

end
% Bruno

 

Tags:

March 22, 2012 0

rsync to copy home directory

By in linux

sudo rsync -ah --exclude-from=/home/thomas/rsyncExcludeFile /home/ /home2/

tailing / are important

the /home/thomas/rsyncExcludeFile file is a file containing directories and files not to sync such as Music

Tags:

March 21, 2012 0

constructing uniform list by specifying starting, end and wished length

By in matlab

Matlab method for constructing a range or vector by specifying start, end and number of wanted elements

the following is an anonymous function
rangeConstructor = @(starting,ending,num) starting:(ending-starting)/(num-1):ending

March 20, 2012 0

tikz ensure equal axis ticks when converting a matlab plot to tikz using matlab2tikz

By in latex, matlab

If you want to ensure the same ticks mark as you have in your matlab plot then this might help

matlab2tikz('latextikzfile.tex','extraAxisOptions',{['xtick={' regexprep(num2str(get(gca,'XTick')),'\s*',',') '}']})

Tags: ,

March 19, 2012 0

Thousand separator in latex when using pgfplot

By in latex

Set thousand separator in latex.

\pgfkeys{/pgf/number format/set thousands separator={}}

Tags:

March 12, 2012 0

Image processing: opening and closing

By in image processing

Opening:

Erosion followed by dilation.

Closing:

Dilation followed by erosion

The operations are not inverse of each others

March 9, 2012 0

Java array initialization

By in java

Allocate memory

int[] intArray = new int[10];

this will be initialized with zeros

int[] intArray={0,0,0,0};

or

int[] intArray=new int[4]{0,0,0,0};

Filling arrays of the primitive types can also be done with

Arrays.fill(intArray,20);

The above will set all indexes in the intArray to 20

The same can be done with classes e.g:

MyClass[] instances = new MyCLass[10];

or (with parameters)

MyClass[] instances = {new MyClass(10,10),new MyClass(10,10),new MyClass(10,10),new MyClass(10,10)};

I’m not sure if objects are actually created with:

MyClass[] instances = new MyCLass[10];

or if every instance will be null

I also dont know if Arrays.fill() can be used on classes