Professional Documents
Culture Documents
PHYS168
Plot in FreeMat
Graph 2-D data with linear scales for both axes Basic Command Syntax:
plot(<data 1>,{linespec 1},<data 2>,{linespec 2}...,properties...) **In general, the linespec is composed of three optional parts, the colorspec, the symbolspec and the linestylespec in any order. Each of these specifications is a single character that determines the corresponding characteristic. Example:
Plot in FreeMat
Example:
Plot in FreeMat
colorspec:
'b' - Color Blue 'g' - Color Green 'r' - Color Red 'c' - Color Cyan 'm' - Color Magenta 'y' - Color Yellow 'k' - Color Black
Plot in FreeMat
The symbolspec specifies the (optional) symbol to be drawn at each data point:
'.' - Dot symbol 'o' - Circle symbol 'x' - Times symbol '+' - Plus symbol '*' - Asterisk symbol 's' - Square symbol 'd' - Diamond symbol 'v' - Downward-pointing triangle symbol '^' - Upward-pointing triangle symbol '<' - Left-pointing triangle symbol '>' - Right-pointing triangle symbol
Plot in FreeMat
The linestylespec specifies the (optional) line style to use for each data series:
'-' - Solid line style ':' - Dotted line style '-.' - Dot-Dash-Dot-Dash line style '--' - Dashed line style
Plot in FreeMat
Example: SUPERIMPOSE MULTIPLE GRAPHS IN ONE CANVAS
x = linspace(-pi,pi); y = [cos(x(:)), cos(3*x(:)), cos(5*x(:))];
plot(x,y)
Plot in FreeMat
Example: SUPERIMPOSE MULTIPLE GRAPHS IN ONE CANVAS
x = linspace(-pi,pi); y = [cos(x(:)), cos(3*x(:)), cos(5*x(:))];
Plot in FreeMat
Example: for
complex matrices
Plot in FreeMat
Example: for
complex matrices
t = linspace(-3,3); plot(cos(5*t).*exp(-t),'r-','linewidth',3);
Plot in FreeMat
Other tweaks in plotting graphs Title title( title here ) Axes labels xlabel( put x-axis label here ) ylabel( put y-axis label here ) Legends legend(legend 1, legend 2, ) axes Range axis([ 0, 10, -1, 1])
Plot in FreeMat
Multiple graphs in a canvas (NOT Superimposed) x = linspace(-pi, pi); subplot(2,2, 1); plot( x, cos( x ) ); subplot(2,2, 2) plot( x, cos(2*x(:) ) ); subplot(2,2, 3); plot( x, cos(5*x(:) ) ); subplot(2,2, 4); plot( x, cos(10*x(:) ) );
Problem 1
Consider the resonant behavior of a forced oscillation. As discussed in many introductory physics textbooks, resonance occurs whenever the frequency of the driving force matches with the natural frequency of the physical system. If the driving force is periodic, the oscillation is expressed as dierential equation,
where m is the mass, k is the spring constant, b is the damping parameter, Fe is the amplitude of the driving force and we is the frequency of the periodic driving force. The solution to this
Problem 1, contd