ECE1250S14 M3LectProbs
ECE1250S14 M3LectProbs
1250
S 14
1.
-93
-95
-96
10
-100
12
-101
16
-106
The following is the script file created in MATLAB in class to plot the above data.
Comments have been added.
% PhoneRSS.m
pairs.
corresponding x values.
plot(d,rss,'r+')
In the lab,
This is
function to fit our data, but then our ability to predict things
p = polyfit(d,rss,1)
rss_hat = polyval(p,d)
line fit.
hold on
% We plot our x and y values, which are d and rss_hat (hat means
%
'estimate' in EE)
plot(d,rss_hat,'b-')
ALWAYS do this!
ylabel('RSS (dB)')
legend('data','fit')
are which.
% Plot title.
% Our last step is to turn off the plot hold so the next time we
%
run this script file, we will start a new plot rather than
2.
1
0
1 1
0
1
0 0
2 0
8 4
0 2 0 4
0
0 2 4
7
6
5 4
1
0
1
2
3
3
The following script file creates the above array. We could just enter all the numbers,
but that becomes impractical for very large matrices. The approach taken here is to
create pieces of the matrix. Think of the pieces as rectangles that we piece together.
As we construct the matrix, we must be sure that we are creating a rectangle at every
step.
% MakeArray.m
% A = 1
-2
0 -2
0 -2
% The ones and zeros arrays complete the first two rows.
%
We are
The last
1, 2, and 3.
A = [A;-2*eye(3),4*ones(3,1),(1:3)']
% Add the last row to the existing A matrix.
%
A = [A; 7:-1:3]
% Our last step is to fix the missing 8 in the center of the
%
matrix.
to 8.
A(3,3) = 8
A =
-2
-2
-2
-2
-2
-2
-2
-2
-2
A =
A =