0 оценок0% нашли этот документ полезным (0 голосов)
86 просмотров7 страниц
MATLAB allows you to process all of the values in a matrix using a single arithmetic operator or function. To create an array with four elements in a single row, separate the elements with either a comma (,) or a space. To create a matrix that has multiple rows, separate the rows with semicolons.
MATLAB allows you to process all of the values in a matrix using a single arithmetic operator or function. To create an array with four elements in a single row, separate the elements with either a comma (,) or a space. To create a matrix that has multiple rows, separate the rows with semicolons.
Авторское право:
Attribution Non-Commercial (BY-NC)
Доступные форматы
Скачайте в формате PDF, TXT или читайте онлайн в Scribd
MATLAB allows you to process all of the values in a matrix using a single arithmetic operator or function. To create an array with four elements in a single row, separate the elements with either a comma (,) or a space. To create a matrix that has multiple rows, separate the rows with semicolons.
Авторское право:
Attribution Non-Commercial (BY-NC)
Доступные форматы
Скачайте в формате PDF, TXT или читайте онлайн в Scribd
Open Matlab and try to understand the following Matlab functions (you can use Matlab help function or online help) Using command prompt: >>help <command name> OR GUI: Click Help tab and then select Product help from drop-down menu. Write the command in upper left search space and ENTER. 1) randn 2) repmat 3) length 4) size 5) sqrt 6) plot 7) semilogy 8) abs 9) sum 10) mean 11) subplot 12) scatterplot 13) hist
Exercise 2: Basic Operation : As a calculator At command prompt >>2+2 ans = 4
>>sin(pi/2) ans= 1
>>log10(100) ans= 2
>>sqrt(16) ans= 4
>>log2(6) ans= 2.5850
Exercise 3: Assignment and variables One can also assign values to variables and then do operations with these variables. For instance; >> x = 2; >>y = x2 y = 4 >> x = pi; >>y = sin(x) y = 0
Notice here that when a semicolon is placed at the end of a command, output is suppressed (i.e. its not printed to the screen).
Exercise 4: Array and Matrix Creation To create an array with four elements in a single row, separate the elements with either a comma (,) or a space. a = [1 2 3 4] Enter a = 1 2 3 4 This type of array is a row vector. To create a matrix that has multiple rows, separate the rows with semicolons. a = [1 2 3; 4 5 6; 7 8 10] a = 1 2 3 4 5 6 7 8 10
Matrices and Arrays Another way to create a matrix is to use a function, such as ones, zeros, or rand. For example, create a 5-by-1 column vector of zeros. z = zeros(5,1) z = 0 0 0 0 0 Matrix and Array Operations MATLAB allows you to process all of the values in a matrix using a single arithmetic operator or function. a + 10 ans = 11 12 13 14 15 16 17 18 20 sin(a) ans = 0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570 0.9894 -0.5440 To transpose a matrix, use a single quote ('): a' ans = 1 4 7 2 5 8
Example : Matlab code in m-file Open a new m-file. Copy-paste below code. Click green run button. If a windows pop up click add path tab.
, 0 2 b e BPSK E P Q N | | = | | \ .
Hint: Matlab does not have built-in function for Q-function. Instead we use it erf function as: ( ) 0.5 0.5 2 x Q x erf | | = | \ .
Therefore
, 0 0.5 0.5* , 2 2 e BPSK b x P erf where E x N | | = | \ . =
Code function verifyFadingmodel() EbN0dB = [0:2:20]; EbN0=10.^(EbN0dB/10); x=sqrt(2*EbN0); BER = 0.5-0.5*(erf(x/sqrt(2)));
semilogy(EbN0dB, BER, 'k-o','LineWidth',2); grid; title('Average BER for BPSK in Rayleigh fading') legend('BPSK'); xlabel('Eb/No[dB]'); ylabel('BER');
Lab 1: Wrire matlab code for symbol error rate for QPSK. (5 marks) Hint: Only change the Line 4 and 5 in above code. Submit matlab code and graph in word file + hardcopy.
Lab 2: Plot the received power Pr with distance d=[1:1:100] in free space. Carrier frequency fc=2.4GHz, Gt=Gr=1, transmit power Pt=20dBm. (5 marks) Submit Matlab code and graph in MS word file + hardcopy.