Monday, March 20, 2017

Week 10:

Part A:
Number 1:

Number 2:
Number 3:
Number 4:
Number 5:
Number 6:
error message: "error using ^ inputs must be a scalar and a square matrix to compute element wise power, use power (.^)  instead."
Number 7:
line width changes the width of the plot line of the graph making it thicker or thinner
Number 8:


MatLab Code:
1
2
3
4
5
6
7
clear all;
close all;
x = [1 2 3 4 5];
y = 2.^x;
plot(x, y, '-or', 'LineWidth',  2, 'MarkerSize', 10)
xlabel('Numbers', 'FontSize', 12)
ylabel('Results', 'FontSize', 12)
Number 9: Nothing happens different when we add in [1;2;3;4;5] instead of [1 2 3 4 5] at least visibly
Number 10:

y = x.^2
plot(x, y, '-or', 'LineWidth',  4, 'MarkerSize', 15)
grid on
set(gcc, 'GridLineStyle', '--'')
Number 11:
a.) Internet sin(30) = .5
b.) MatLab sin(30) = -.9880
b.) Sin of 30 degrees in MatLab is sind(30)
Number 12:

MatLab Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
clear all;
close all;

tc = linspace(0,.125, 10);
tf = linspace(0,.125, 1000);

yc = 10*sin(100*tc);
yf = 10*sin(100*tf);

plot(tc, yc, '-or', 'LineWidth', 1, 'MarkerSize', 6)
hold on
plot(tf, yf, '-k', 'LineWidth', 1, 'MarkerSize', 2)

xlim([0 .14])

xlabel('Time (s)', 'FontSize', 12)
ylabel('y function', 'FontSize', 12)
legend('Coarse','Fine')
Number 13:
Number 14:


MatLab Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
clear all;
close all;

tc = linspace(0,.125, 10);
tf = linspace(0,.125, 1000);

yc = 10*sin(100*tc);
yf = 10*sin(100*tf);
yff = find(yf<5);

plot(tc, yc, '-or', 'LineWidth', 1, 'MarkerSize', 6)
hold on
plot(tf(yff), yf(yff), '-k', 'LineWidth', 1, 'MarkerSize', 2)

xlim([0 .14])

xlabel('Time (s)', 'FontSize', 12)
ylabel('y function', 'FontSize', 12)
legend('Coarse','Fine')
PartB:
Low Pass Filter

MatLab Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
clear all;
close all;


x = [50 100 200 300 400 500 600 700 800 850 860 870 880 890 895 900 1000 1200 1400 1600 1800 2000];
y = [5.95 5.9 5.75 5.55 5.31 5.06 4.81 4.57 4.34 4.28 4.24 4.22 4.2 4.18 4.16 4.12 3.92 3.57 3.26 3.00 2.77 2.58 ];
y = y/5.94;

plot(x, y, '-or', 'LineWidth', 1, 'MarkerSize', 6)
hold on
refline(0,0.707);

xlabel('Frequency', 'FontSize', 12)
ylabel('Output/Input', 'FontSize', 12)
High Pass Filter
MatLab Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
clear all;
close all;


x = [50 100 300 600 800 850 860 870 880 890 895 900 910 920 930 940 950 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3500 4000 4500 5000];
y = [.4 .747 2 3.34 3.94 4.05 4.07 4.08 4.1 4.12 4.14 4.14 4.17 4.19 4.22 4.24 4.25 4.36 4.67 4.91 5.09 5.23 5.34 5.42 5.5 5.56 5.6 5.64 5.73 5.8 5.85 5.93];
y = y/5.94;

plot(x, y, '-or', 'LineWidth', 1, 'MarkerSize', 6)
hold on
refline(0,0.707);

xlabel('Frequency', 'FontSize', 12)
ylabel('Output/Input', 'FontSize', 12)

No comments:

Post a Comment