How to plot a gene graph for a DNA sequence say ATGCCGCTGCGC?

I did not previously know of Mark McClure’s blog about Chaos Game representation of gene sequences, but it reminded me of an article by Jose Manuel GutiĆ©rrez (The Mathematica Journal Vol 9 Issue 2), which also gives a chaos game algorithm for an IFS using (the four bases of) DNA sequences. A detailed description may … Read more

Fastest Matlab file reading?

Problem statement This is a common struggle, and there is nothing like a test to answer. Here are my assumptions: A well formatted ASCII file, containing two columns of numbers. No headers, no inconsistent lines etc. The method must scale to reading files that are too large to be contained in memory, (although my patience … Read more

How to save a figure in MATLAB from the command line?

Use saveas: h=figure; plot(x,y,’-bs’,’Linewidth’,1.4,’Markersize’,10); % … saveas(h,name,’fig’) saveas(h,name,’jpg’) This way, the figure is plotted, and automatically saved to ‘.jpg’ and ‘.fig’. You don’t need to wait for the plot to appear and click ‘save as’ in the menu. Way to go if you need to plot/save a lot of figures. If you really do not … Read more

Plot a plane based on a normal vector and a point in Matlab or matplotlib

For all the copy/pasters out there, here is similar code for Python using matplotlib: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D point = np.array([1, 2, 3]) normal = np.array([1, 1, 2]) # a plane is a*x+b*y+c*z+d=0 # [a,b,c] is the normal. Thus, we have to calculate # d and we’re … Read more

Where is startup.m supposed to be?

The best method, I find, is this. Let’s say you want MATLAB to start up in mystartupdir, and you’ve placed startup.m in that directory. On Windows, make a shortcut icon to MATLAB, then right-click on it and select Properties. Edit the field Start In. Now, use this icon whenever you want to start MATLAB. On … Read more

How can I convert an RGB image to grayscale but keep one color?

One option which greatly improves the quality of the resulting image is to convert to a different color space in order to more easily select your colors. In particular, the HSV color space defines pixel colors in terms of their hue (the color), saturation (the amount of color), and value (the brightness of the color). … Read more

Labeling points in order in a plot

Here’s one way to do this: p = rand(10,2); labels = cellstr( num2str([1:10]’) ); %’ # labels correspond to their order plot(p(:,1), p(:,2), ‘rx’) text(p(:,1), p(:,2), labels, ‘VerticalAlignment’,’bottom’, … ‘HorizontalAlignment’,’right’)