PART A: MATLAB practice.
1. Open MATLAB. Open the editor and copy paste the following code. Name your code as FirstCode.m
Save the resulting plot as a JPEG image and put it here.
clear all;
Graph1.1: graph of the code below. 
y = 2.^x;
plot(x, y, 'LineWidth', 6)
xlabel('Numbers', 'FontSize', 12)
ylabel('Results', 'FontSize', 12)
2. What does clear all do?
Clear all will clear all the variables from the current work space
3. What does close all do?
Close all deletes all figures in the workspace except those that end in a semi colon
4. In the command line, type x and press enter. This is a matrix. How many rows and columns are there in the matrix?
1 row and 5 columns
5. Why is there a semicolon at the end of the line of x and y?
It allows the user to enter the data into the code but not display it on the outcome. This is useful if the outcome is large or if they want to display the outcome in a graph only.
6. Remove the dot on the y = 2.^x; line and execute the code again. What does the error message mean?
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
The error message is saying that we need a dot after the y to so the y will be the base and the x value will be the exponent.
7. How does the LineWidth affect the plot? Explain.
Line width affects the thickness of the line in the plot. By changing the value of LineWidth we able to either increase or decrease the thickness of the line on the plot.
8. Type help plot on the command line and study the options for plot command. Provide how you would change the line for plot command to obtain the following figure (Hint: Like ‘LineWidth’, there is another property called ‘MarkerSize’)
We used the code below to change the plot from the first question to match the plot above
plot(x, y, 'ro','LineWidth', 5, 'MarkerSize', 18, 'MarkerEdgeColor', 'r')
our plot is below
Graph8.1: shows the plot after changing the line width. 
9. What happens if you change the line for x to x = [1; 2; 3; 4; 5]; ? Explain.
The matrix created by x = [1 2 3 4 5] is 1 row 5 columns, but when you change the code to x = [1;2;3;4;5] the matrix is changed to a 5 rows 1 column, even if you do this the plot does not change
10. Provide the code for the following figure. You need to figure out the function for y. Notice there are grids on the plot.
We used the code below to change the our plot to look like the one above
clear all;
close all;
x = [1 2 3 4 5];
y = 2.^x;
plot(x, y, ':sk','LineWidth', 8, 'MarkerSize', 20)
grid
xlabel('Numbers', 'FontSize', 12)
ylabel('Results', 'FontSize', 12)
Graph 10.1: shows the plot of the code above. 
11. Degree vs. radian in MATLAB:
a. Calculate sinus of 30 degrees using a calculator or internet.
using a calculator of the internet we found sin(30)= 0.5
b. Type sin(30) in the command line of the MATLAB. Why is this number different? (Hint: MATLAB treats angles as radians).
In the MATLAB sin(30)= 0.9880
When we calculate numbers in MATLAB the angles will be treated in radians not in degree.
To change the angles in degree we add d to the sin and the angles will be in degree, sind(30) = 0.5000
12. Plot y = 10 sin (100 t) using Matlab with two different resolutions on the same plot: 10 points per period and 1000 points per period. The plot needs to show only two periods. Commands you might need to use are linspace, plot, hold on, legend, xlabel, and ylabel. Provide your code and resulting figure. The output figure should look like the following:
clear all;
close all;
t = linspace(0,pi/25,1000);
x = linspace(0,pi/25,10);
y = 10 * sin(100*t);
z = 10 * sin(100*x);
plot(t, y, 'k', 'LineWidth', 1)
hold on
plot(x, z, 'or','LineWidth', 1, 'MarkerSize', 5)
hold off
legend('Coarse','Fine',0);
xlabel('Time (s)', 'FontSize', 12)
ylabel('y function', 'FontSize', 12)
Graph 12.1: shows the plot of the code above. 
13. Explain what is changed in the following plot comparing to the previous one.
The graph above is different because on the (t,y) plot there is a maximum cap of 5 on the plot.
14. The command find was used to create this code. Study the use of find (help find) and try to replicate the plot above. Provide your code.
clear all;
close all;
t = linspace(0,pi/25,1000);
x = linspace(0,pi/25,10);
y = 10 * sin(100*t);
z = 10 * sin(100*x);
k=(y>5);
y(k)=5;
plot(t, y, 'k', 'LineWidth', 1)
hold on
plot(x, z, 'or','LineWidth', 1, 'MarkerSize', 5)
hold off
legend('Fine','Coarse',0);
xlabel('Time (s)', 'FontSize', 12)
ylabel('y function', 'FontSize', 12)
Graph 14.1: shows the plot of the code above.
PART B: Filters and MATLAB
1. Build a low pass filter using a resistor and capacitor in which the cut off frequency is 1 kHz. Observe the output signal using the oscilloscope. Collect several data points particularly around the cut off frequency. Provide your data in a table.
Table 1.1: show the values of Vout/Vin for low pass filter.
For the low pass filter we used 2V pkpk as the input voltage, and from the table we know that the cut off frequency is between .18 and .23 KHz. I think we got this low frequency because we may be used different values of capacitor and resistor. I think we used a bigger capacitor than the one we were supposed to use.
2. Plot your data using MATLAB. Make sure to use proper labels for the plot and make your plot line and fonts readable. Provide your code and the plot.
clc;
clear all;
x=linspace(0,1.5,22);
y=[0 1.90 1.80 1.72 1.60 1.54 1.44 1.36 1.28 1.24 1.02 0.86 0.76 0.66 0.6 0.54 0.48 0.46 0.42 0.4 0.36 0.34];
z=y./(2);
plot(x,y,'k')
xlabel('Frequency (kHz)')
ylabel('Vout (V)')
title('Low Pass Filter Data')
Graph 2.1: show the line of low pass filter. 
clear all;
close all;
vin = [2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00
2.00 2.00 2.00 2.00 ];
vout = [0 1.90 1.80 1.72 1.60
1.54 1.44 1.36 1.28 1.24 1.02 0.86 0.76 0.66 0.6 0.54 0.48 0.46 0.42 0.4 0.36
0.34];
x = [0 .10 .13 .15 .18 .2 .23 .25 .28 .2 .4 .5
.6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5];
y = vout / vin;
plot(x, y, 'ro','LineWidth', 2, 'MarkerSize', 8, 'MarkerEdgeColor', 'k')
xlabel('Frequency(KHz', 'FontSize', 12)
ylabel('Vout / Vin (V)', 'FontSize', 12)
k = find (vout>.18, .23, 'last')
x(k)
4. Put a horizontal dashed line on the previous plot that passes through the cutoff frequency.
Graph4.1: shows the line that passes through the cut off frequency. 
5. Repeat 13 by modifying the circuit to a high pass filter.
a)
Table 5.1: show the values of vout/vin for high pass filter.

b)
clc;
clear all;
x=linspace(0,1.5,22);
y=[0 1.04 1.18 1.28 1.44 1.52 1.62 1.66 1.74 1.78 1.92 1.96 2.04 2.08 2.08 2.10 2.12 2.14 2.14 2.14 2.14 2.16];
z=y./(2);
plot(x,y,'k')
xlabel('Frequency (kHz)')
ylabel('Vout (V)')
title('Low Pass Filter Data')

clear all;
close all;
vin = [2.00 2.00 2.00 2.00 2.00 2.00 2.00 2.00
2.00 2.00 2.00 2.00 ];
Vout=[0 1.04
1.18 1.28 1.44 1.52 1.62 1.66 1.74 1.78 1.92 1.96 2.04 2.08 2.08 2.10 2.12 2.14
2.14 2.14 2.14 2.16];
x = [0 .10 .13 .15 .18 .2 .23 .25 .28 .2 .4 .5
.6 .7 .8 .9 1 1.1 1.2 1.3 1.4 1.5];
y = vout / vin;
plot(x, y, 'ro','LineWidth', 2, 'MarkerSize', 8, 'MarkerEdgeColor', 'k')
xlabel('Frequency(KHz', 'FontSize', 12)
ylabel('Vout / Vin (V)', 'FontSize', 12)
k = find (vout>.18, .23, 'last')
x(k)
the code for cut off frequency in high pass filter