Feed on
Posts
Comments

Archive for the 'Matlab' Category

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);

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.

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

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

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

identify cpu hogging matlab code

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

cast a cell as a string

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)

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

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

copy a matlab array into excel

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

« Prev

More blogs about http://desk.stinkpot.org:8080/tricks.