Monthly Archives: February 2011

<code>M = rand(10,2);
x = 1:size(M,1);
plot(x, M(:,1), 'b.-', x, M(:,2), 'g.-')
legend('M1', 'M2')
for i=x
    text(i+0.1, M(i,1), sprintf('%.2f', M(i,1)), 'fontsize',7, 'color','b' );
    text(i+0.1, M(i,2), sprintf('%.2f', M(i,2)), 'fontsize',7, 'color','g' );

alt text

Alternatively, you can use:


which will enable the user to just point and click on points to see the data label.

You can label each axis with the function:


These can also take cell arguments, where each row is a new line. That’s handy for showing units. Labeling each point on the figure can be done as so:

<code>for i=1:length(M)
    text(M(i,1),M(i,2),'Label Text')

The label text can also be a string variable that you can edit with sprintf and make special strings for each point.

Matlab multi line plot in the same window.

There are two common ways to plot more than 2 data on the same window.

The first method uses one line and is of the form plot(xfunction, style#1 ,x, function#2style#2, ). For example,

The second method involves the use of the “hold on” and “hold off” commands. After creating the first graph, use the “hold on” command, forcing subsequent graphing commands to be placed in the same window. Now type in your second plot command. When you are through, type “hold off”. For example

hold on

To add labels to your axes, use the following

xlabel(‘this goes across’)
ylabel(‘this goes up)
hold off

Latex: Numbered Subsubsections

LaTex lets you break the document down into chapters, sections, subsections, subsubsections and paragraphs. By default subsubsections and paragraphs are not numbered or included in the table of contents. Sometimes this might be desirable. However, I usually find that in cases when I do not need them numbered, I usually never use them (ie. my documents are broken down by chapter, section, and subsection only). At other times, when I desire more granularity, I actually want subsubsections to show up in the TOC and have distinctive headings and numbers.

To enable this you will need to put 2 lines of code somewhere in your preamble:


The first line enables numbering of subsubsections. The second line includes subsubsections in the table of contents.

Btw, if you need to break down your document even more you can switch 3 to 4 in these lines to enable numbering for paragraphs.