230 likes | 708 Views
Matlab 101. For Beginners. Overview. The Matlab Environment Vectors Matrices Plotting and Graphics Statistics Basic Calculus. The Matlab Environment. Vectors. Inputting vectors: >> a = [4,5,7,8] %% a(2) = 5 Common operations Transpose of a >> a’ =
E N D
Matlab 101 For Beginners
Overview • The Matlab Environment • Vectors • Matrices • Plotting and Graphics • Statistics • Basic Calculus
Vectors • Inputting vectors: >> a = [4,5,7,8] %% a(2) = 5 • Common operations • Transpose of a >> a’ = • Adding components >> sum(a) = 24
Vector Arithmetic • >> a = [5,0]; • >> b = [3,4]; • Find magnitude of a • >> X = a.*a • >> Y = sum(X) • >> mag = sqrt(Y) • Find angle between a and b using • a.b = |a||b|cos(Ө)
Matrices • >> A = [1,-2,1; 3,4,5; -2,1,7] • A = • rank(A) • Inv(A) • Det(A)
Matrix Arithmetic • Solve the linear system using matlab • X-2Y+Z=12; 3X+4Y+5Z=20; -2X+Y+7Z=11 • Ax=B: A = B = • >> C = inv(A) • >>x = C*B • X = A\B
Plotting and Graphics • Plot the graph of cos(x) for 0<x<10 • x=[0:0.1:10]
Plotting and Graphics • >> x = [0:0.1:10]; • >> y = cos(x); • >>plot(x,y),xlabel('x'),ylabel('cos(x)')
Statistics • Differential Equations grades for Final Exam
Statistics • X = [95, 90, 85, 80, 75, 70, 65, 60, 55, 50,0]; • Y = [1,2,1,6,4,7,2,1,3,2,4]; • bar(x,y)
Basic Calculus • Finding limits: find
Basic Calculus • Draw and find
Solving differential equations • Derivative of f >> diff(f) • nthderivative of f >> diff(f,n) • >> D2y +2*Dy=5*sin(7*x) • Solve the above equation with