Showing posts with label MATLAB. Show all posts
Showing posts with label MATLAB. Show all posts

Sunday, January 24, 2016

Matlab misc searches 2015

Various searches that I did while tweaking the Matlab demonstration algorithm from Tom:

A link about the matrix multiplication function in Matlab. The rule of thumb that I tried to remember about matrix multiplication is that the result is an array of the sums of multiplying each element of a row by the matching element of a column. This page also shows the syntax of how rows and columns are defined in Matlab, with columns being separated by semicolons and row elements being separated by spaceshttp://www.mathworks.com/help/matlab/ref/mtimes.html

A link about the matrix inverse function in Matlab. This page fails to reference the textbook definition of matrix inverse, but does have a couple of useful examples of using matrix inverse to solve linear equations. http://www.mathworks.com/help/matlab/ref/inv.html?refresh=true

The full tutorial on matrix indexing. The most important thing to remember is that the starting index for accessing matrixes in Matlab is 1, not 0. http://www.mathworks.com/help/matlab/math/matrix-indexing.html?refresh=true

A similar tutorial but this one is Array indexing: http://www.mathworks.com/help/matlab/learn_matlab/array-indexing.html

More on how to define matrixes: http://www.mathworks.com/help/stateflow/ug/how-to-define-vectors-and-matrices.html?refresh=true

How to do most common operations you'd want to do on matrixes, including defining, multiplying, inverting, concatinating, and printing: http://www.mathworks.com/help/matlab/learn_matlab/matrices-and-arrays.html

An answer to the question of how to format print output in Matlab, in this case how to format floating point number printing. I needed this while putting debug statements in the Matlab code, although it wasn't important for the final product: http://www.mathworks.com/matlabcentral/answers/99743-how-can-i-change-the-way-matlab-displays-the-significant-digits-of-floating-point-numbers

The matlab line continuation character (spoiler, it's weirdly an ellipsis, which is to say '...'): https://www.mathworks.com/matlabcentral/newsreader/view_thread/173340

The syntax for Matlab For Loops. TL;DR is if you have anything with a quantity, this allows you to perform an act on each item in the quantity: http://www.mathworks.com/matlabcentral/answers/31156-how-do-i-create-a-for-loop-in-matlab

The man page for one of MATLAB's most powerful function, one that gives you a matrix of all of the results of evaluating a polynomial on a matrix of inputs, POLYVAL. This is a very natural thing to use when computing least squares fits! http://www.mathworks.com/help/matlab/ref/polyval.html



Thursday, April 12, 2012

GNU equivalent to MATLAB

Octave, or more completely Octave-forge, seems to be the free alternative to MATLAB. Since we can't buy another MATLAB license for our laptop, this was worth investigating.

Long story short, Octave can run MATLAB scripts without any modification, except for all the pieces in our code which make use of the "Fixed Point Toolbox". Octave has a Fixed Point Toolbox of its own, but it was written from scratch prior to MATLAB's and is not syntax compatible in any way.

As an aside, all the Fixed Point stuff seems universally to be used to model FPGA implementations, both in MATLAB and Octave. Makes sense.

So, if I wanted to completely rewrite our fixed point code, I could run Octave instead of MATLAB. It's almost worth it, but not quite.

Here's how to download binaries for Octave for Mac:

http://octave.org/wiki/index.php?title=Octave_for_Mac

Here's something short on the relatively minor compatibility issues between Octave and MATLAB (doesn't mention the fixed point toolbox):

http://www.csse.uwa.edu.au/~pk/research/matlabfns/octaveinfo.html

Here's something much longer on portability between MATLAB and Octave (doesn't mention the fixed-point toolbox, but a sidebar about MATLAB alone has a link to info on using MATALAB's toolbox):

http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB

Here is what seems to be the last word from the author of the Octave Fixed Point Toolbox himself, about why it's not getting any more support and why it's never going to be syntax compatible:

http://octave.1599824.n4.nabble.com/Fixed-point-arithmetic-td2284793.html

Lastly, what is with these "Free downloads" for Matlab for Mac? Given that you have to wait for a call back from Mathworks to get a trial version, not to mention their heinous price structure that has left many forum threads full of tears, how are these even out there? How likely are they to have the Fixed Point Toolbox anyhow?

http://mac.brothersoft.com/matlab.html
http://download.cnet.com/Matlab/3000-2053_4-2777.html

Thursday, March 22, 2012

IDL, MATLAB scp command imbedding

For my IDL and MATLAB scripts, calling scp is as easy as using each language's system call, with command strings built up through normal concatination.

IDL:
In IDL it's the "spawn" command. Here are some nice tutorials with examples:

http://archive.stsci.edu/iue/manual/dacguide/node8.html
http://www.astro.virginia.edu/class/oconnell/astr511/idl_5.1_html/idl1a9.htm
http://idlastro.gsfc.nasa.gov/idl_html_help/SPAWN.html


MATLAB:
This shows a very fancy script, but it's just a wrapper for the system call that allows specification of an array of scenarios for the scp command. The take-away for me was to be sure to use the full path for the scp executable.

http://www.mathworks.com/matlabcentral/fileexchange/25256-scpsftp-from-matlab/content/ssh/scpfrommatlab.m

MATLAB concatinate strings trailing space

Concatinating strings is easy with result = strcat(s1,s2,...sN) except that strcat trims trailing space from each string, ruining attempts at formatting. The solution is to think in terms of MATLAB's array addition. In this case, you simply declare result = [s1 s2 ... SN].

http://www.mathworks.com/help/techdoc/ref/strcat.html