Archive for the ‘matlab’ Category

February 10, 2014 0

Matlab: calling a function handle with parameters from a cell array

By in matlab

Having a function handle sometimes means that you want to be flexible regarding the number of input arguments. having a function handle fhandle=@plot means that you can call fhandle() but is you want to pass a variable number of arguments to fhandle that resides in a cell array, cparameters, containing e.g.: cparameters={[1:10],’resize’,’no’} you can do: […]

Tags: , , ,

February 10, 2014 0

date string in matlab to autogenerate filenames

By in matlab

generate file names using the current date and time. e.g. filename=[datestr(now(),’yyyy-mm-dd HH:MM’) ‘ preprocessed data.txt’]; generates: 2014-02-10 16:40 preprocessed data.txt

Tags: , ,

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 […]

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 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: ,

February 15, 2012 0

Using XML files to store data in matlab

By in matlab

In my experience matlab handles xml DOM model by using tool from a java library. Links to use when working with xml files through matlab http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/package-summary.html http://www.mathworks.se/help/techdoc/import_export/f5-86078.html#bsmnj5u

February 14, 2012 0

matlab: add data to the file name string before save

By in matlab

Here is the simple line dateString = datestr(now(),’dd-mmm-yyyy’);