2+3*4
ans =
14
2*3^4
ans =
162
2/3/4
ans =
0.1667
(2/3)/4
ans =
0.1667
2/(3/4)
ans =
2.6667
2e5
ans =
200000
pi
ans =
3.1416
format long
pi
ans =
3.14159265358979
format
pi
ans =
3.1416
i
ans =
0 + 1.0000i
j
ans =
0 + 1.0000i
p2=pi^2
p2 =
9.8696
p3=1/p2
p3 =
0.1013
P3
??? Undefined function or variable 'P3'.
1/0
Warning: Divide by zero.
ans =
Inf
0/0
Warning: Divide by zero.
ans =
NaN
Inf+2
ans =
Inf
exp(2)
ans =
7.3891
e=exp(1)
e =
2.7183
sin(3)
ans =
0.1411
cosd(90)
ans =
0
asin(.5)
ans =
0.5236
log(2)
ans =
0.6931
log10(2)
ans =
0.3010
sqrt(5)
ans =
2.2361
6!
??? 6!
|
Error: Unexpected MATLAB operator.
factorial(6)
ans =
720
erf(2)
ans =
0.9953
besselj(0,4)
ans =
-0.3971
i^2
ans =
-1
sqrt(-4)
ans =
0 + 2.0000i
log(-1)
ans =
0 + 3.1416i
exp(i*pi)
ans =
-1.0000 + 0.0000i
i^i
ans =
0.2079
cos(4+3*i)
ans =
-6.5807 + 7.5816i
A=[1 2 ;3 4]
A =
1 2
3 4
A=[1 2
3 4]
A =
1 2
3 4
B=[2 0;-1 5]
B =
2 0
-1 5
2*A+3*B
ans =
8 4
3 23
A*B
ans =
0 10
2 20
A^2
ans =
7 10
15 22
C=[1 2 1;3 2 4]
C =
1 2 1
3 2 4
A*C
ans =
7 6 9
15 14 19
C*A
??? Error using ==> mtimes
Inner matrix dimensions must agree.
C(1,2)
ans =
2
C(1,2)=7
C =
1 7 1
3 2 4
C(1:2,2:3)
ans =
7 1
2 4
C(1,:)
ans =
1 7 1
D=[A C]
D =
1 2 1 7 1
3 4 3 2 4
D=[A;B]
D =
1 2
3 4
2 0
-1 5
D=[A;C]
??? Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.
C*D(1:3,:)
ans =
24 30
17 14
b=[3;5]
b =
3
5
x=A\b
x =
-1
2
A*x
ans =
3
5
A/b
??? Error using ==> mrdivide
Matrix dimensions must agree.
inv(A)
ans =
-2.0000 1.0000
1.5000 -0.5000
x=inv(A)*b
x =
-1.0000
2.0000
det(A)
ans =
-2
eye(10)
ans =
1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
zeros(4,5)
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
x=linspace(1,4);
x=linspace(1,4,301);
x=x';
x=linspace(1,4,301);
x=x(:);
y=exp(-x);
plot(x,y)
dx=.1
dx =
0.1000
x=1:dx:4;
x=x(:);
y=exp(-x).*sin(3*x);
plot(x,y)
shg
z=cos(5*x)-2;
plot(x,y,x,z);shg
axis([1 4 -4 2]);shg
plot(x,y,'m--');shg
plot(x,y,'m--+');shg
help plot
PLOT Linear plot.
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, length(Y)
disconnected points are plotted.
PLOT(Y) plots the columns of Y versus their index.
If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).
In all other uses of PLOT, the imaginary part is ignored.
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.
For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a
solid yellow line interpolating green circles at the data points.
The PLOT command, if no color is specified, makes automatic use of
the colors specified by the axes ColorOrder property. The default
ColorOrder is listed in the table above for color systems where the
default is blue for one line, and for multiple lines, to cycle
through the first six colors in the table. For monochrome systems,
PLOT cycles over the axes LineStyleOrder property.
If you do not specify a marker type, PLOT uses no marker.
If you do not specify a line style, PLOT uses a solid line.
PLOT(AX,...) plots into the axes with handle AX.
PLOT returns a column vector of handles to lineseries objects, one
handle per plotted line.
The X,Y pairs, or X,Y,S triples, can be followed by
parameter/value pairs to specify additional properties
of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0])
will create a plot with a dark red line width of 2 points.
Backwards compatibility
PLOT('v6',...) creates line objects instead of lineseries
objects for compatibility with MATLAB 6.5 and earlier.
See also plottools, semilogx, semilogy, loglog, plotyy, plot3, grid,
title, xlabel, ylabel, axis, axes, hold, legend, subplot, scatter.
Reference page in Help browser
doc plot
help linspace
LINSPACE Linearly spaced vector.
LINSPACE(X1, X2) generates a row vector of 100 linearly
equally spaced points between X1 and X2.
LINSPACE(X1, X2, N) generates N points between X1 and X2.
For N < 2, LINSPACE returns X2.
Class support for inputs X1,X2:
float: double, single
See also logspace, :..
Reference page in Help browser
doc linspace
doc linspace
helpdesk
help eigenvalue
eigenvalue.m not found.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
lookfor eigenvalue
ROSSER Classic symmetric eigenvalue test problem.
WILKINSON Wilkinson's eigenvalue test matrix.
BALANCE Diagonal scaling to improve eigenvalue accuracy.
CONDEIG Condition number with respect to eigenvalues.
EIG Eigenvalues and eigenvectors.
ORDEIG Eigenvalues of quasitriangular matrices.
ORDQZ Reorder eigenvalues in QZ factorization.
ORDSCHUR Reorder eigenvalues in Schur factorization.
POLYEIG Polynomial eigenvalue problem.
QZ QZ factorization for generalized eigenvalues.
EIGS Find a few eigenvalues and eigenvectors of a matrix using ARPACK
EIGMOVIE Symmetric eigenvalue movie.
EIGSHOW Graphical demonstration of eigenvalues and singular values.
EXPMDEMO3 Matrix exponential via eigenvalues and eigenvectors.
MAT4BVP Find the fourth eigenvalue of the Mathieu's equation.
EIG Symbolic eigenvalues and eigenvectors.
HANOWA Matrix whose eigenvalues lie on a vertical line.
LESP Tridiagonal matrix with real, sensitive eigenvalues.
RANDCORR Random correlation matrix with specified eigenvalues.
quit