% Useful general Matlab commands % Victoria Hsiao, 01/11/13 clear all; % clears all variables from the workspace clc; %clears the command window close all; %closes all figure windows %Suppress all outputs from appearing in the command window %with a semi-colon %Comment your code with the percent symbol %Creating a vector V1 = [1 2]; %This creates a vector with one row, two columns V2 = [1; 2]; %This creates a vector with two rows, one column %Plotting t = 0:1:100; %This says go from 0 to 100 in increments of 1. x = 5.*(0:1:100); %multiplies everything in the vector by 5 x2 = 10.*(0:1:100); plot(t,x); % your basic plot command figure; %opens a new figure instead of overwriting your previous one % You can add additional options like color 'r' and linestyle '--' % Type 'doc plot' in the command window for a complete set plot(t,x,'r--','linewidth',2) hold on %Allows you to plot on the same graph plot(t,x2,'b--','linewidth',1) %Labeling your plot xlabel('Time','fontsize',14); % You don't have to define fontsize ylabel('X concentration') title('T versus X','fontsize',16); legend('X','X2') %creates a legend in the order that you plotted them in