root/ResearchApps/PHY/WARPLAB/WARPLab_SISO_MIMO2x2/M_Code/warplab_mimo_example_ChannelEstim_WorkshopExercise_Solution.m

Revision 839, 19.9 kB (checked in by MelissaDuarte, 4 months ago)

WARPLab Release 02 April 09 2008. Release for 2x2 MIMO and improved SISO. Matlab code is modified to support MIMO. SISO now supports continuous transmission. There is one bitstream for MIMO and one bitstream for SISO. The xps project for MIMO and SISO is different but the M code is the same (The 'warplab_' functions are the same, the argument input to the functions is the only thing that changes from SISO to MIMO).

Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% Using Warplab to Estimate the Amplitude and Phase of a Narrowband Flat
3% Fading 2-Input 2-Output Wireless Channel (2x2 MIMO Configuration)
4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5% To run this code the boards must be programmed with the
6% warplab_mimo_v02.bit bitstream
7
8% The specific steps implemented in this script are the following:
9
10% 0. Transmit a narrowband signal using Warplab. For 2x2 channel estimation
11% first silence Tx radio 3 and transmit from Tx radio 2, then silence Tx
12% radio 2 and transmit from Tx radio 3. During both transimissions both
13% receive radios are capturing data.
14% 1. Remove from the received vectors the samples that do not correspond to
15% transmitted data.
16% 2. Compute the amplitude and the phase of the transmitted and received
17% samples
18% 3. Compute the channel amplitude and channel phase per sample for each of
19% the 4 SISO channels, and compute the channel matrix
20
21% NOTE 1: The amplitude and phase computed in this exercise correspond to the
22% amplitude and phase of the channel together with the amplitude and phase
23% of the hardware. In other words, the effect of the radios is also part of
24% the channel.
25
26% You will write a matlab script that implements the four steps above.
27% Part of the code is provided, some part of the code you will write. Read
28% the code below and fill in with your code wherever you are asked to do
29% so.
30
31% NOTE 2 : To avoid conflict with other groups using the boards, please
32% test the code you write in this script in any of the following three
33% ways:
34%
35% Option 1. Run this script from matlab's Command Window by entering the
36% name of the script (enter warplab_example_ChannelEstimation_WorkshopExercise
37% in matlab's Command Window).
38% Option 2. In the menu bar go to Debug and select Run. If there
39% are errors in the code, error messages will appear in the Command Window.
40% Option 3. Press F5. If the are errors in the code, error messages will
41% appear in the Command Window.
42%
43% DO NOT USE the Evaluate selection option and DO NOT run the script by
44% sections. To test any change, always run the whole script by following
45% any of the three options above.
46
47try,
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49% Code to avoid conflict between users, only needed for the workshop, go to
50% step 0 below to transmit a narrowband signal using Warplab
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52fid = fopen('c:\boards_lock.txt');
53
54if(fid > -1)
55    fclose('all');
56        errordlg('Boards already in use - Please try again!');
57        return;
58end
59
60!echo > c:\boards_lock.txt
61
62%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63% 0. Transmit a narrowband signal using Warplab. For 2x2 channel estimation
64% first silence Tx radio 3 and transmit from Tx radio 2, then silence Tx
65% radio 2 and transmit from Tx radio 3. During both transimissions both
66% receive radios are capturing data.
67%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68
69%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70% 0.0. Initializaton and definition of parameters
71%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72%Load some global definitions (packet types, etc.)
73warplab_defines
74
75% Create Socket handles and intialize nodes
76[socketHandles, packetNum] = warplab_initialize;
77
78%Separate the socket handles for easier access
79% The first socket handle is always the magic SYNC
80% The rest can be arranged in any combination of Tx and Rx
81udp_Sync = socketHandles(1);
82udp_Tx = socketHandles(2);
83udp_RxA = socketHandles(3);
84
85% Define the warplab options (parameters)
86CaptOffset = 1000; %Number of noise samples per Rx capture; in [0:2^14]
87TxLength = 2^14-1000; %Length of transmission; in [0:2^14-CaptOffset]
88TransMode = 0; %Transmission mode; in [0:1]
89               % 0: Single Transmission
90               % 1: Continuous Transmission. Tx board will continue
91               % transmitting the vector of samples until the user manually
92               % disables the transmitter.
93CarrierChannel = 8; % Channel in the 2.4 GHz band. In [1:14]
94Tx2GainBB = 3; %Tx Baseband Gain in [0:3]
95Tx2GainRF = 40; %Tx RF Gain in [0:63]
96Rx2GainBB = 15; %Rx Baseband Gain in [0:31]
97Rx2GainRF = 1; %Rx RF Gain in [1:3]
98Tx3GainBB = 3; %Tx Baseband Gain in [0:3]
99Tx3GainRF = 40; %Tx RF Gain in [0:63]
100Rx3GainBB = 15; %Rx Baseband Gain in [0:31]
101Rx3GainRF = 1; %Rx RF Gain in [1:3]
102TxSelect = 2; % Select transmitter radio [0:2] 0:Radio2, 1:Radio3, 2: Both
103RxSelect = 2; % Select transmitter radio [0:2] 0:Radio2, 1:Radio3, 2: Both
104
105% Define the options vector; the order of options is set by the FPGA's code
106% (C code)
107optionsVector = [CaptOffset TxLength-1 TransMode CarrierChannel (Rx2GainBB + Rx2GainRF*2^16) (Tx2GainRF + Tx2GainBB*2^16) (Rx3GainBB + Rx3GainRF*2^16) (Tx3GainRF + Tx3GainBB*2^16) TxSelect RxSelect];
108% Send options vector to the nodes
109warplab_setOptions(socketHandles,optionsVector);
110
111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112% 0.1. Generate a vector of samples to transmit and send the samples to the
113% Warp board (Sample Frequency is 40MHz)
114%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115% Prepare some data to be transmitted
116t = 0:(1/40e6):TxLength/40e6 - 1/40e6; %Create time vector.
117TxData = exp(t*j*2*pi*1e6); % Create a signal to transmit. Signal must be a
118% row vector
119
120% Download the samples to be transmitted to Tx radio 2 buffer
121warplab_writeSMWO(udp_Tx, TxData, RADIO2_TXDATA);
122
123% Download the samples to be transmitted to Tx radio 3 buffer
124warplab_writeSMWO(udp_Tx, TxData, RADIO3_TXDATA);
125
126%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127% 0.2 Prepare boards for transmission from Tx radio 2 and reception on
128% both receiver antennas. Send trigger to start transmission and reception
129% (trigger is the SYNC packet)
130%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131% Enable transmitter radio path on radio 2 in transmitter node (enable
132% radio 2 in transmitter node as transmitter)
133warplab_sendCmd(udp_Tx, RADIO2_TXEN, packetNum);
134
135% Enable receiver radio path in receiver node (enable radio 2 and
136% radio 3 in receiver node as receivers)
137warplab_sendCmd(udp_RxA, [RADIO2_RXEN RADIO3_RXEN], packetNum);
138
139% Prime transmitter state machine in transmitter node. Transmitter will be
140% waiting for the SYNC packet. Transmission will be triggered when the
141% transmitter node receives the SYNC packet.
142warplab_sendCmd(udp_Tx, TX_START, packetNum);
143
144% Prime receiver state machine in receiver node. Receiver will be waiting
145% for the SYNC packet. Capture will be triggered when the receiver
146% node receives the SYNC packet.
147warplab_sendCmd(udp_RxA, RX_START, packetNum);
148
149% Send the SYNC packet
150warplab_sendSync(udp_Sync);
151
152%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153% 0.3 Read the received smaples from the Warp board
154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155% Read back the received samples from Rx radio2
156[Tx2_Rx2_RawRxData] = warplab_readSMRO(udp_RxA, RADIO2_RXDATA, TxLength+CaptOffset);
157% Process the received samples to obtain meaningful data
158[Tx2_Rx2_RxData,Tx2_Rx2_RxOTR] = warplab_processRawRxData(Tx2_Rx2_RawRxData);
159% Read stored RSSI data
160[Tx2_Rx2_RawRSSIData] = warplab_readSMRO(udp_RxA, RADIO2_RSSIDATA, (TxLength+CaptOffset)/8);
161% Procecss Raw RSSI data to obtain meningful RSSI values
162[Tx2_Rx2_RxRSSI] = warplab_processRawRSSIData(Tx2_Rx2_RawRSSIData);
163
164% Read back the received samples from Rx radio3
165[Tx2_Rx3_RawRxData] = warplab_readSMRO(udp_RxA, RADIO3_RXDATA, TxLength+CaptOffset);
166% Process the received samples to obtain meaningful data
167[Tx2_Rx3_RxData,Tx2_Rx3_RxOTR] = warplab_processRawRxData(Tx2_Rx3_RawRxData);
168% Read stored RSSI data
169[Tx2_Rx3_RawRSSIData] = warplab_readSMRO(udp_RxA, RADIO3_RSSIDATA, (TxLength+CaptOffset)/8);
170% Procecss Raw RSSI data to obtain meningful RSSI values
171[Tx2_Rx3_RxRSSI] = warplab_processRawRSSIData(Tx2_Rx3_RawRSSIData);
172
173%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174% 0.4 Reset and disable the boards
175%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176% Reset the receiver
177warplab_sendCmd(udp_RxA, RX_DONEREADING, packetNum);
178
179% Disable the receiver radio 2 and radio 3
180warplab_sendCmd(udp_RxA, [RADIO2_RXDIS RADIO3_RXDIS], packetNum);
181
182% Disable the transmitter radio 2
183warplab_sendCmd(udp_Tx, RADIO2_TXDIS, packetNum);
184
185%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186% 0.5 Prepare boards for transmission from Tx radio 3 and reception on
187% both receiver antennas. Send trigger to start transmission and reception
188% (trigger is the SYNC packet)
189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190% Enable transmitter radio path on radio 3 in transmitter node (enable
191% radio 3 in transmitter node as transmitter)
192warplab_sendCmd(udp_Tx, RADIO3_TXEN, packetNum);
193
194% Enable receiver radio path in receiver node (enable radio 2 and
195% radio 3 in receiver node as receivers)
196warplab_sendCmd(udp_RxA, [RADIO2_RXEN RADIO3_RXEN], packetNum);
197
198% Prime transmitter state machine in transmitter node. Transmitter will be
199% waiting for the SYNC packet. Transmission will be triggered when the
200% transmitter node receives the SYNC packet.
201warplab_sendCmd(udp_Tx, TX_START, packetNum);
202
203% Prime receiver state machine in receiver node. Receiver will be waiting
204% for the SYNC packet. Capture will be triggered when the receiver
205% node receives the SYNC packet.
206warplab_sendCmd(udp_RxA, RX_START, packetNum);
207
208% Send the SYNC packet
209warplab_sendSync(udp_Sync);
210
211
212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213% 0.6 Read the received smaples from the Warp board
214%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215% Read back the received samples from Rx radio2
216[Tx3_Rx2_RawRxData] = warplab_readSMRO(udp_RxA, RADIO2_RXDATA, TxLength+CaptOffset);
217% Process the received samples to obtain meaningful data
218[Tx3_Rx2_RxData,Tx3_Rx2_RxOTR] = warplab_processRawRxData(Tx3_Rx2_RawRxData);
219% Read stored RSSI data
220[Tx3_Rx2_RawRSSIData] = warplab_readSMRO(udp_RxA, RADIO2_RSSIDATA, (TxLength+CaptOffset)/8);
221% Procecss Raw RSSI data to obtain meningful RSSI values
222[Tx3_Rx2_RxRSSI] = warplab_processRawRSSIData(Tx3_Rx2_RawRSSIData);
223
224% Read back the received samples from Rx radio3
225[Tx3_Rx3_RawRxData] = warplab_readSMRO(udp_RxA, RADIO3_RXDATA, TxLength+CaptOffset);
226% Process the received samples to obtain meaningful data
227[Tx3_Rx3_RxData,Tx3_Rx3_RxOTR] = warplab_processRawRxData(Tx3_Rx3_RawRxData);
228% Read stored RSSI data
229[Tx3_Rx3_RawRSSIData] = warplab_readSMRO(udp_RxA, RADIO3_RSSIDATA, (TxLength+CaptOffset)/8);
230% Procecss Raw RSSI data to obtain meningful RSSI values
231[Tx3_Rx3_RxRSSI] = warplab_processRawRSSIData(Tx3_Rx3_RawRSSIData);
232
233%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234% 0.7 Reset and disable the boards
235%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236% Reset the receiver
237warplab_sendCmd(udp_RxA, RX_DONEREADING, packetNum);
238
239% Disable the receiver radio 2 and radio 3
240warplab_sendCmd(udp_RxA, [RADIO2_RXDIS RADIO3_RXDIS], packetNum);
241
242% Disable the transmitter radio 3
243warplab_sendCmd(udp_Tx, RADIO3_TXDIS, packetNum);
244
245% Close sockets
246pnet('closeall');
247
248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249% 0.8 Plot the transmitted and received data
250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251figure;
252subplot(5,2,1);
253plot(real(TxData));
254title('Tx Radio 2 I and Tx Radio 3 I ');
255xlabel('n (samples)'); ylabel('Amplitude');
256axis([0 2^14 -1 1]); % Set axis ranges.
257subplot(5,2,2);
258plot(imag(TxData));
259title('Tx Radio 2 Q Tx Radio 3 Q ');
260xlabel('n (samples)'); ylabel('Amplitude');
261axis([0 2^14 -1 1]); % Set axis ranges.
262subplot(5,2,3);
263plot(real(Tx2_Rx2_RxData));
264title('Rx Radio 2 I when Tx Radio 2 was transmitting');
265xlabel('n (samples)'); ylabel('Amplitude');
266axis([0 2^14 -1 1]); % Set axis ranges.
267subplot(5,2,4);
268plot(imag(Tx2_Rx2_RxData));
269title('Rx Radio 2 Q when Tx Radio 2 was transmitting');
270xlabel('n (samples)'); ylabel('Amplitude');
271axis([0 2^14 -1 1]); % Set axis ranges.
272subplot(5,2,5);
273plot(real(Tx2_Rx3_RxData));
274title('Rx Radio 3 I when Tx Radio 2 was transmitting');
275xlabel('n (samples)'); ylabel('Amplitude');
276axis([0 2^14 -1 1]); % Set axis ranges.
277subplot(5,2,6);
278plot(imag(Tx2_Rx3_RxData));
279title('Rx Radio 3 Q when Tx Radio 2 was transmitting');
280xlabel('n (samples)'); ylabel('Amplitude');
281axis([0 2^14 -1 1]); % Set axis ranges.
282subplot(5,2,7);
283plot(real(Tx3_Rx2_RxData));
284title('Rx Radio 2 I when Tx Radio 3 was transmitting');
285xlabel('n (samples)'); ylabel('Amplitude');
286axis([0 2^14 -1 1]); % Set axis ranges.
287subplot(5,2,8);
288plot(imag(Tx3_Rx2_RxData));
289title('Rx Radio 2 Q when Tx Radio 3 was transmitting');
290xlabel('n (samples)'); ylabel('Amplitude');
291axis([0 2^14 -1 1]); % Set axis ranges.
292subplot(5,2,9);
293plot(real(Tx3_Rx3_RxData));
294title('Rx Radio 3 I when Tx Radio 3 was transmitting');
295xlabel('n (samples)'); ylabel('Amplitude');
296axis([0 2^14 -1 1]); % Set axis ranges.
297subplot(5,2,10);
298plot(imag(Tx3_Rx3_RxData));
299title('Rx Radio 3 Q when Tx Radio 3 was transmitting');
300xlabel('n (samples)'); ylabel('Amplitude');
301axis([0 2^14 -1 1]); % Set axis ranges.
302
303%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304% 1. Remove from the received vector the samples that do not correspond to
305% transmitted data. In other words, remove from the received vector samples
306% 1 to CaptOffset. This step will remove samples that correspond to measured
307% noise and make the RxData vector the same length as the TxData vector
308%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309Tx2_Rx2_RxData = Tx2_Rx2_RxData(CaptOffset+1:end);
310Tx2_Rx3_RxData = Tx2_Rx3_RxData(CaptOffset+1:end);
311Tx3_Rx2_RxData = Tx3_Rx2_RxData(CaptOffset+1:end);
312Tx3_Rx3_RxData = Tx3_Rx3_RxData(CaptOffset+1:end);
313
314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315% 2. Compute the amplitude and the phase of the transmitted and received
316% sammples
317%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318% Compute the magnitude per sample of the transmitted and received
319% data
320mag_TxData = abs(TxData); % Tx data
321mag_Tx2_Rx2_RxData = abs(Tx2_Rx2_RxData);
322mag_Tx2_Rx3_RxData = abs(Tx2_Rx3_RxData);
323mag_Tx3_Rx2_RxData = abs(Tx3_Rx2_RxData);
324mag_Tx3_Rx3_RxData = abs(Tx3_Rx3_RxData);
325
326% Compute the phase per sample of the transmitted data
327phase_TxData = angle(TxData);
328phase_TxData_unw = unwrap(phase_TxData);
329phase_TxData = phase_TxData *180/pi; %Convert to degrees
330phase_TxData_unw = phase_TxData_unw *180/pi; %Convert to degrees
331
332phase_Tx2_Rx2_RxData = angle(Tx2_Rx2_RxData);
333phase_Tx2_Rx2_RxData_unw = unwrap(phase_Tx2_Rx2_RxData);
334phase_Tx2_Rx2_RxData = phase_Tx2_Rx2_RxData *180/pi; %Convert to degrees
335phase_Tx2_Rx2_RxData_unw = phase_Tx2_Rx2_RxData_unw *180/pi; %Convert to degrees
336
337phase_Tx2_Rx3_RxData = angle(Tx2_Rx3_RxData);
338phase_Tx2_Rx3_RxData_unw = unwrap(phase_Tx2_Rx3_RxData);
339phase_Tx2_Rx3_RxData = phase_Tx2_Rx3_RxData *180/pi; %Convert to degrees
340phase_Tx2_Rx3_RxData_unw = phase_Tx2_Rx3_RxData_unw *180/pi; %Convert to degrees
341
342phase_Tx3_Rx2_RxData = angle(Tx3_Rx2_RxData);
343phase_Tx3_Rx2_RxData_unw = unwrap(phase_Tx3_Rx2_RxData);
344phase_Tx3_Rx2_RxData = phase_Tx3_Rx2_RxData *180/pi; %Convert to degrees
345phase_Tx3_Rx2_RxData_unw = phase_Tx3_Rx2_RxData_unw *180/pi; %Convert to degrees
346
347phase_Tx3_Rx3_RxData = angle(Tx3_Rx3_RxData);
348phase_Tx3_Rx3_RxData_unw = unwrap(phase_Tx3_Rx3_RxData);
349phase_Tx3_Rx3_RxData = phase_Tx3_Rx3_RxData *180/pi; %Convert to degrees
350phase_Tx3_Rx3_RxData_unw = phase_Tx3_Rx3_RxData_unw *180/pi; %Convert to degrees
351
352% Plot magnitude and phase of transmitted and received samples
353figure;
354subplot(5,2,1);
355plot(mag_TxData);
356title('Tx Radio 2 magnitude and Tx Radio 3 magnitude ');
357xlabel('n (samples)'); ylabel('Amplitude');
358subplot(5,2,2);
359plot(phase_TxData_unw);
360title('Tx Radio 2 phase Tx Radio 3 phase ');
361xlabel('n (samples)'); ylabel('Amplitude');
362subplot(5,2,3);
363plot(mag_Tx2_Rx2_RxData);
364title('Rx Radio 2 magnitude when Tx Radio 2 was transmitting');
365xlabel('n (samples)'); ylabel('Amplitude');
366subplot(5,2,4);
367plot(phase_Tx2_Rx2_RxData_unw);
368title('Rx Radio 2 phase when Tx Radio 2 was transmitting');
369xlabel('n (samples)'); ylabel('Amplitude');
370subplot(5,2,5);
371plot(mag_Tx2_Rx3_RxData);
372title('Rx Radio 3 magnitude when Tx Radio 2 was transmitting');
373xlabel('n (samples)'); ylabel('Amplitude');
374subplot(5,2,6);
375plot(phase_Tx2_Rx3_RxData_unw);
376title('Rx Radio 3 phase when Tx Radio 2 was transmitting');
377xlabel('n (samples)'); ylabel('Amplitude');
378subplot(5,2,7);
379plot(mag_Tx3_Rx2_RxData);
380title('Rx Radio 2 magnitude when Tx Radio 3 was transmitting');
381xlabel('n (samples)'); ylabel('Amplitude');
382subplot(5,2,8);
383plot(phase_Tx3_Rx2_RxData_unw);
384title('Rx Radio 2 phase when Tx Radio 3 was transmitting');
385xlabel('n (samples)'); ylabel('Amplitude');
386subplot(5,2,9);
387plot(mag_Tx3_Rx3_RxData);
388title('Rx Radio 3 magnitude when Tx Radio 3 was transmitting');
389xlabel('n (samples)'); ylabel('Amplitude');
390subplot(5,2,10);
391plot(phase_Tx3_Rx3_RxData_unw);
392title('Rx Radio 3 phase when Tx Radio 3 was transmitting');
393xlabel('n (samples)'); ylabel('Amplitude');
394
395% Plot magnitude and phase of transmitted and received samples
396
397%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398% 3. Compute the channel amplitude and channel phase per sample
399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400% Compute the channel amplitudes
401channel_amplitude_Tx2_Rx2 = mag_Tx2_Rx2_RxData./mag_TxData;
402channel_amplitude_Tx2_Rx3 = mag_Tx2_Rx3_RxData./mag_TxData;
403channel_amplitude_Tx3_Rx2 = mag_Tx3_Rx2_RxData./mag_TxData;
404channel_amplitude_Tx3_Rx3 = mag_Tx3_Rx3_RxData./mag_TxData;
405
406% Compute the channel phases
407channel_phase_Tx2_Rx2 = phase_Tx2_Rx2_RxData_unw - phase_TxData_unw;
408channel_phase_Tx2_Rx3 = phase_Tx2_Rx3_RxData_unw - phase_TxData_unw;
409channel_phase_Tx3_Rx2 = phase_Tx3_Rx2_RxData_unw - phase_TxData_unw;
410channel_phase_Tx3_Rx3 = phase_Tx3_Rx3_RxData_unw - phase_TxData_unw;
411
412% Plot channel amplitude
413figure
414subplot(2,2,1)
415plot(channel_amplitude_Tx2_Rx2)
416title('Tx2-Rx2 path - Channel Amplitude per sample')
417xlabel('n (samples)'); ylabel('Amplitude');
418subplot(2,2,2)
419plot(channel_amplitude_Tx2_Rx3)
420title('Tx2-Rx3 path - Channel Amplitude per sample')
421xlabel('n (samples)'); ylabel('Amplitude');
422subplot(2,2,3)
423plot(channel_amplitude_Tx3_Rx2)
424title('Tx3-Rx2 path - Channel Amplitude per sample')
425xlabel('n (samples)'); ylabel('Amplitude');
426subplot(2,2,4)
427plot(channel_amplitude_Tx3_Rx3)
428title('Tx3-Rx3 path - Channel Amplitude per sample')
429xlabel('n (samples)'); ylabel('Amplitude');
430
431%Plot channel phase
432figure
433subplot(2,2,1)
434plot(channel_phase_Tx2_Rx2)
435xlabel('n (samples)'); ylabel('Degrees');
436title('Tx2-Rx2 path - Channel Phase per sample')
437subplot(2,2,2)
438plot(channel_phase_Tx2_Rx3)
439xlabel('n (samples)'); ylabel('Degrees');
440title('Tx2-Rx3 path - Channel Phase per sample')
441subplot(2,2,3)
442plot(channel_phase_Tx3_Rx2)
443xlabel('n (samples)'); ylabel('Degrees');
444title('Tx3-Rx2 path - Channel Phase per sample')
445subplot(2,2,4)
446plot(channel_phase_Tx3_Rx3)
447xlabel('n (samples)'); ylabel('Degrees');
448title('Tx3-Rx3 path - Channel Phase per sample')
449
450%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451% Code to avoid conflict between users, only needed for the workshop
452%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
453pnet('closeall');
454!del c:\boards_lock.txt
455catch,
456% Close sockets
457pnet('closeall');
458!del c:\boards_lock.txt
459lasterr
460end
Note: See TracBrowser for help on using the browser.