0% found this document useful (0 votes)
58 views4 pages

MATLAB Complex Number Calculations

This document provides an introduction to using MATLAB for complex arithmetic and plotting functions. It includes examples of using functions like real(), imag(), abs(), angle() to work with complex numbers. Practice problems are provided to work with complex numbers in both rectangular and polar form. The document also demonstrates how to plot functions and define custom functions in MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views4 pages

MATLAB Complex Number Calculations

This document provides an introduction to using MATLAB for complex arithmetic and plotting functions. It includes examples of using functions like real(), imag(), abs(), angle() to work with complex numbers. Practice problems are provided to work with complex numbers in both rectangular and polar form. The document also demonstrates how to plot functions and define custom functions in MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ECE 2610 Lab Worksheet:

MATLAB Intro & Complex Arithmetic


1/21/2011

MATLAB as a Complex Number Calculator

Functions used: real(), imag(), abs(), angle()

Compare the three angle producing functions: angle(), atan2(), and atan()

Practice Problems (very similar to Set #1)


For each of the problem below work out the answer using both MATLAB and your calculator
1. Write 127 j75 in polar form; find the angle in both radians and degrees.
>> z = 127 - j*75;

>> abs(z) = _________________

>> angle(z) = _________________

Hand/Calculator workspace:
Using a TI-89

2. Write z = 22 110 in rectangular form.


>> z = 22*exp(-j*110*pi/180);

>> _______________________________________________
>> _______________________________________________
MATLAB as a Complex Number Calculator

ECE 2610 Lab Worksheet: MATLAB Intro & Complex Arithmetic

Spring 2011

Hand/Calculator workspace:

3. Evaluate z = 15 j37 60 45 to a rectangular form solution.


MATLAB Steps:

Hand/Calculator workspace:

4. Evaluate z = 15 j37 60 45 to a polar form solution.


MATLAB Steps:

Hand/Calculator workspace:

MATLAB as a Complex Number Calculator

ECE 2610 Lab Worksheet: MATLAB Intro & Complex Arithmetic

Spring 2011

MATLAB for Plotting Data and Functions


Functions used: plot(), xlabel(), ylabel(), title(), grid, and axis
1. Plot x t = 25 sin t 5 + 4 for 0 t 15 s. Include a grid and axis labels.
>> t = 0:.1:15; % create a time axis vector with sample spacing 0.1s
>> ?

For the x t above, plot x t 2 for 0 t 15 s, overlaid on the plot of x t of part (1).
>> hold on % will hold the previous plot so you can overlay a new plot
>> ?

MATLAB for Plotting Data and Functions

ECE 2610 Lab Worksheet: MATLAB Intro & Complex Arithmetic

Spring 2011

User Defined Functions in MATLAB


One of the most power capabilities of Matlab is being able write your own user defined functions.
Consider a custom trig function of the form
y t = 3 cos 5t + 4 sin 3t

(1)

The input to this function is time, t , and the output is y . The function prototype we require is of
the form:
function y = my_trig(t)
% y = my_trig(t) is a function that evaluates the simple trig
% based function y = 3*cos(5t) + 4*sin(3*t).
%
% Author: My Name
% Date: January 2011
%

function body

make sure that you return output to variable y

Write the Function

Test the Function


To test the function input a time vector that runs from -2s to 10s using a time step of 0.05s. Output
the results in a plot using plot(t,y).

User Defined Functions in MATLAB

You might also like