






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to using matlab for basic mathematical calculations, managing the workspace and variables, handling comments and complex numbers, and utilizing mathematical functions. It covers topics such as simple math, the matlab workspace, variable naming rules, comments and punctuation, complex numbers, and mathematical functions. Examples are given for each concept.
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!







2ans 2(25+(3exp(1)))*
ans = 160 ans = 56 ans = 112 ans = 66.
t_initial=4; t_final=12; t_elapsed=t_final-t_initial rate= distance=rate(t_elapsed)*
t_elapsed = 8 rate = 5 distance = 40
l=3; w=12; A=lw; A l,w,A*
l = 3 w = 12 A = 36
who
Your variables are:
A distance rate t_final w ans l t_elapsed t_initial
int_nominal=0.08; % Loan interest rate (per year) int_monthly=int_nominal/12; % Loan interest rate (per month) P=270000; % Loan Amount n_years=30; % Duration of loan (in years) n_months=n_years12; % Duration of loan (in months) x=(1+int_monthly)^n_months; A=P(int_monthlyx)/(x-1) % Monthly installment to repay loan*
A = 1.9812e+
l=3; w=4; d=5; V=lwd**
r=2, h=5 % Cone radius and height V=(1/3)pir^2h % Volume of Cone*
r = 2 h = 5 V = 20.
x=0.5; sum=1/(1-x) % Computes the sum of the infinite geometric series % 1 + x + x^2 + x^3 + x^4 + x^5 + ......
sum = 2
Re_z=3; Im_z=4; z1=Re_z + jIm_z % z1 is a complex number z2=Re_z - jIm_z % z2 is the complex conjugate of z u=sqrt(z1z2) % Find the magnitude of z1 and its conjugate z v=z1/z2 % Complex number v is the quotient of z1 and z w=z2v % Complex number w is the product of z2 and v (restores z1) y=u(v+w)*
z1 = 3.0000 + 4.0000i z2 = 3.0000 - 4.0000i u = 5 v = -0.2800 + 0.9600i w = 3.0000 + 4.0000i y = 13.6000 +24.8000i
x=3; % Real part of complex number y=4; % Imaginary part of complex number z=x+yi % Complex number in rectangular form R=abs(z) % Computes the magnitude of z theta=angle(z) % Computes the angle(rad) of z theta_deg=180theta/pi; % Converts theta to degrees**
z = 3.0000 + 4.0000i R = 5 theta = 0.
matlab/elmat - Elementary matrices and matrix manipulation matlab/elfun - Elementary math functions matlab/specfun - Specialized math functions matlab/datafun - Data analysis and Fourier transforms matlab/polyfun - Interpolation and polynomials matlab/funfun - Function functions and ode solvers matlab/sparfun - Sparse matrices
Trigonometric. sin - Sine. sinh - Hyperbolic sine. asin - Inverse sine. asinh - Inverse hyperbolic sine. cos - Cosine. cosh - Hyperbolic cosine. acos - Inverse cosine. acosh - Inverse hyperbolic cosine. tan - Tangent. tanh - Hyperbolic tangent. atan - Inverse tangent. atan2 - Four quadrant inverse tangent. atanh - Inverse hyperbolic tangent. sec - Secant. sech - Hyperbolic secant. asec - Inverse secant. asech - Inverse hyperbolic secant. csc - Cosecant. csch - Hyperbolic cosecant. acsc - Inverse cosecant. acsch - Inverse hyperbolic cosecant. cot - Cotangent. coth - Hyperbolic cotangent. acot - Inverse cotangent.
Exponential. exp - Exponential. log - Natural logarithm. log10 - Common (base 10) logarithm. log2 - Base 2 logarithm.
pow2 - Base 2 power and scale floating point number. sqrt - Square root. nextpow2 - Next higher power of 2.
Complex. abs - Absolute value. angle - Phase angle. complex - Construct complex data from real and imaginary parts. conj - Complex conjugate. imag - Complex imaginary part. real - Complex real part. unwrap - Unwrap phase angle. isreal - True for real array. cplxpair - Sort numbers into complex conjugate pairs.
Rounding and remainder. fix - Round towards zero. floor - Round towards minus infinity. ceil - Round towards plus infinity. round - Round towards nearest integer. mod - Modulus (signed remainder after division). rem - Remainder after division. sign - Signum.
REM Remainder after division. REM(x,y) is x - y.*fix(x./y) if y ~= 0. By convention, REM(x,0) is NaN. The input x and y must be real arrays of the same size, or real scalars.
REM(x,y) has the same sign as x while MOD(x,y) has the same sign as y. REM(x,y) and MOD(x,y) are equal if x and y have the same sign, but differ by y if x and y have different signs.
REM is a built-in function. An M-file for REM would be the same as MOD with "floor" replaced by "fix".
% A sample of the Trigonometric Functions in MATLAB theta1= pi/6 % Angle (in rad) theta1_deg=180theta1/pi % Angle (in deg) x=sin(theta1) % Sine function theta2=atan(1) % Inverse tangent function (in rad)*
% A sample of Rounding and Remainder Functions in MATLAB a=9; b=5; c=-5; x1=fix(a/b) % Round toward zero x2=floor(a/c) % Round toward minus infinity x3=ceil(a/c) % Round toward plus infinity x4=rem(a,b) % Remainder after division x5=sign(b-a) % Signum function
x1 = 1 x2 = - x3 = - x4 = 4 x5 = -
CART2SPH Transform Cartesian to spherical coordinates. [TH,PHI,R] = CART2SPH(X,Y,Z) transforms corresponding elements of data stored in Cartesian coordinates X,Y,Z to spherical coordinates (azimuth TH, elevation PHI, and radius R). The arrays X,Y, and Z must be the same size (or any of them can be scalar). TH and PHI are returned in radians.
TH is the counterclockwise angle in the xy plane measured from the positive x axis. PHI is the elevation angle from the xy plane.
See also CART2POL, SPH2CART, POL2CART.
% A sample of Coordinate Transformation Functions in MATLAB x1=3,y1=4, [th1,r1]=cart2pol(x1,y1) % Cartesian to polar cart2pol(x1,y1) % Will return only the first output in 'ans' th2=th1+pi r2=r1; [x2,y2]=pol2cart(th2,r2) % Polar to Cartesian
x1 = 3 y1 = 4 th1 = 0. r1 = 5 ans = 0. th2 = 4. x2 = -3. y2 = -4.