EE421/Lab 03 Visualization and Programming: - O + X S D V P N
EE421/Lab 03 Visualization and Programming: - O + X S D V P N
Objectives:
We want to practice the use of figures in Matleb. Also, we want acquired
knowledge about how use functions in programming or as user.
Pre_Lab:
I – plotting
In general, on can use the function plot to draw figure owing x, y vectors according to x-axis
and y-axis.
plot(X,Y)
We can add or rectify color dot form and line form according to the table:
Triangle ^
up
Triangle <
left
Triangle >
right
pentagram p
hexagram N
II – programing
We can program by using m-file or a function. The function are more powerful in matlab
because it gives chance to take inputs and gives outputs.
In_Lab:
1
EE421/Lab 03 Visualization and Programming
=================================================================
I - Plotting
1. Given x intervals and functions, write m-files containing the commands producing the
figures:
x=0:pi/20:4*pi;
2
EE421/Lab 03 Visualization and Programming
x=0:pi/20:4*pi;
x1=-10:10; x2=(x1)2
II- Programming
1. Write a function named “R_eq” where we can calculate the equivalent of two
resistances. Tacking in consideration (series or parallels)
3
EE421/Lab 03 Visualization and Programming
a) (10k //1k)+12k
b) (5k+10k+0.2k)//1k
c) ((2k//10k)+(5k//4k))//120k
1) defines x =[0:0.1:100]
2) calculates 𝑓(𝑥) = exp(−𝐴𝑡 + 𝑗2𝜋𝑓 𝑡)) by taking 𝐴 and 𝑓 as inputs of the
function.
3) plots the real and the complex part , the module and the phase in the same figure
(use real, imag, angel abs and subplot)
4) Plots f(x) in 3D using another figure.
5) The output is the vector Y continuing f(x) values.