Posted in Matlab on July 18th, 2006 No Comments »
let’s say you’ve got y = f(x), where x and y are both matlab arrays. to numerically integrate f(x), just use the command trapz: >> area_under_the_curve = trapz(x,y);
Posted in LaTeX, Matlab on March 31st, 2006 6 Comments »
manually writing out matlab matrices in latex is really tedious. here’s how to save yourself the time: assume you have some matrix L >> s = sym(L); >> v = vpa(s,5); # assign numerical precision >> latex(v) matlab should now spit out the latex source code that you can directly copy into your .tex file.
Posted in Matlab on March 4th, 2006 39 Comments »
a friend asked: matlab question: i have an array of data. how do i get matlab to find the position of an entry closest to some arbitrary value? for instance, i would have a= [1; 4; 6; 8; 12] i want to search for 9 and have matlab spit back 4, the entry in a [...]
Posted in Matlab on March 4th, 2006 1 Comment »
a friend asked: matlab question: i have an array of data. how do i get matlab to find the position of an entry closest to some arbitrary value? for instance, i would have a= [1; 4; 6; 8; 12] i want to search for 9 and have matlab spit back 4, the entry in a [...]
Posted in Matlab on February 20th, 2006 2 Comments »
for some reason or another, i can’t get dbstop to work (running matlab7 on “os x”). even manually setting a breakpoint in the matlab editor doesn’t work. as expected, this makes debugging quite difficult. fortunately, i’ve rediscovered this handy function: keyboard just stick this in wherever you’d like your code to pause and grant you [...]
Posted in Matlab on February 18th, 2006 No Comments »
often, you’ll write code in matlab that will take forever to run. if you’re lucky, it’s simply because you’ve written inefficient code. to try and identify locations where you can speed up matlab running time, use the profile tool. try this: >>profile on >>your_script_here >>profile viewer an applet should appear which allows you to drill [...]
Posted in Matlab on February 15th, 2006 7 Comments »
if you receive the error “Function is not defined for ‘cell’ inputs” while trying to print a string, it’s because your string lives in a cell. to make this go away, cast the cell contents into a char: >>char(your_string_trapped_in_a_cell)
Posted in Matlab on February 15th, 2006 10 Comments »
[update: a much easier solution]save ‘my_file.name’ my_array_or_matrix -ASCII -TABS to write a file in matlab, you first need to get a file id: >> fid = fopen(‘nameofyourfile.txt’,’w’) (the ‘w’ means that this file will completely overwrite whatever file shares the same filename) to write to the file, use the fprint command: >> fprintf(fid,’%d’,5); this puts [...]
Posted in Matlab, MySQL on February 10th, 2006 14 Comments »
i’ve been working on a gene identification / network modeling experiment for a couple of weeks now. i have tons of processed microarray data that now needs to be examined as well as further annotated by hand. since all the data has already been processed, a spreadsheeting package is unncessary; what i really need is [...]
Posted in Matlab on January 29th, 2006 7 Comments »
although matlab programmers are loath to admit it, there are circumstances during which we are forced to use excel. in such trying times, here’s a quick script that i found on matlab central for copying an array in an excel-readable format onto the clipboard. to use it, save the code below the asterisks as num2clip.m. [...]