source: ResearchApps/PHY/WARPLAB/WARPLab_v05_2/M_Code_Examples/warplab_mimo_2x2_example_ChannelEstim.m

Last change on this file was 1311, checked in by mduarte, 15 years ago

Adding files for WARPLab release 05

File size: 21.3 KB
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% The specific steps implemented in this script are the following:
6
7% 0. Transmit a narrowband signal using Warplab. For 2x2 channel estimation
8% first silence Tx radio 3 and transmit from Tx radio 2, then silence Tx
9% radio 2 and transmit from Tx radio 3. During both transimissions both
10% receive radios are capturing data.
11% 1. Remove from the received vectors the samples that do not correspond to
12% transmitted data.
13% 2. Compute the amplitude and the phase of the transmitted and received
14% samples
15% 3. Compute the channel amplitude and channel phase per sample for each of
16% the 4 SISO channels, and compute the channel matrix
17
18% Note: The amplitude and phase computed in this exercise correspond to the
19% amplitude and phase of the channel together with the amplitude and phase
20% of the hardware. In other words, the effect of the radios is also part of
21% the channel.
22
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24% 0. Transmit a narrowband signal using Warplab. For 2x2 channel estimation
25% first silence Tx radio 3 and transmit from Tx radio 2, then silence Tx
26% radio 2 and transmit from Tx radio 3. During both transimissions both
27% receive radios are capturing data.
28%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31% 0.0. Initializaton and definition of parameters
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33%Load some global definitions (packet types, etc.)
34warplab_defines
35
36% Create Socket handles and intialize nodes
37[socketHandles, packetNum] = warplab_initialize;
38
39% Separate the socket handles for easier access
40% The first socket handle is always the magic SYNC
41% The rest of the handles are the handles to the WARP nodes
42udp_Sync = socketHandles(1);
43udp_node1 = socketHandles(2);
44udp_node2 = socketHandles(3);
45
46% Define WARPLab parameters.
47TxDelay = 1000; % Number of noise samples per Rx capture. In [0:2^14]
48TxLength = 2^14-1-1000; % Length of transmission. In [0:2^14-1-TxDelay]
49TxMode = 0; % Transmission mode. In [0:1]
50            % 0: Single Transmission
51            % 1: Continuous Transmission. Tx board will continue
52            % transmitting the vector of samples until the user manually
53            % disables the transmitter.
54CarrierChannel = 12; % Channel in the 2.4 GHz band. In [1:14]
55Node1_Radio2_TxGain_BB = 3; % Tx Baseband Gain. In [0:3]
56Node1_Radio2_TxGain_RF = 40; % Tx RF Gain. In [0:63]
57Node1_Radio3_TxGain_BB = 3; % Tx Baseband Gain. In [0:3]
58Node1_Radio3_TxGain_RF = 40; % Tx RF Gain. In [0:63]
59Node2_Radio2_RxGain_BB = 13; % Rx Baseband Gain. In [0:31]
60Node2_Radio2_RxGain_RF = 1; % Rx RF Gain. In [1:3] 
61Node2_Radio3_RxGain_BB = 13; % Rx Baseband Gain. In [0:31]
62Node2_Radio3_RxGain_RF = 1; % Rx RF Gain. In [1:3] 
63% Note: For this experiment node 1 will be set as the transmitter and node
64% 2 will be set as the receiver (this is done later in the code), hence,
65% there is no need to define receive gains for node1 and there is no
66% need to define transmitter gains for node2.
67Node2_MGC_AGC_Select = 0;   % Set MGC_AGC_Select=1 to enable Automatic Gain Control (AGC).
68                            % Set MGC_AGC_Select=0 to enable Manual Gain Control (MGC).
69                            % By default, the nodes are set to MGC. 
70
71% Download the WARPLab parameters to the WARP nodes.
72% The nodes store the TxDelay, TxLength, and TxMode parameters in
73% registers defined in the WARPLab sysgen model. The nodes set radio
74% related parameters CarrierChannel, TxGains, and RxGains, using the
75% radio controller functions.
76% The TxDelay, TxLength, and TxMode parameters need to be known at the transmitter;
77% the receiver doesn't require knowledge of these parameters (the receiver
78% will always capture 2^14 samples). For this exercise node 1 will be set as
79% the transmitter (this is done later in the code). Since TxDelay, TxLength and
80% TxMode are only required at the transmitter we download the TxDelay, TxLength and
81% TxMode parameters only to the transmitter node (node 1).
82warplab_writeRegister(udp_node1,TX_DELAY,TxDelay);
83warplab_writeRegister(udp_node1,TX_LENGTH,TxLength);
84warplab_writeRegister(udp_node1,TX_MODE,TxMode);
85% The CarrierChannel parameter must be downloaded to all nodes 
86warplab_setRadioParameter(udp_node1,CARRIER_CHANNEL,CarrierChannel);
87warplab_setRadioParameter(udp_node2,CARRIER_CHANNEL,CarrierChannel);
88% Node 1 will be set as the transmitter so download Tx gains to node 1.
89warplab_setRadioParameter(udp_node1,RADIO2_TXGAINS,(Node1_Radio2_TxGain_RF + Node1_Radio2_TxGain_BB*2^16));
90warplab_setRadioParameter(udp_node1,RADIO3_TXGAINS,(Node1_Radio3_TxGain_RF + Node1_Radio3_TxGain_BB*2^16));
91% Node 2 will be set as the receiver so download Rx gains to node 2.
92warplab_setRadioParameter(udp_node2,RADIO2_RXGAINS,(Node2_Radio2_RxGain_BB + Node2_Radio2_RxGain_RF*2^16));
93warplab_setRadioParameter(udp_node2,RADIO3_RXGAINS,(Node2_Radio3_RxGain_BB + Node2_Radio3_RxGain_RF*2^16));
94% Set MGC mode in node 2 (receiver)
95warplab_setAGCParameter(udp_node2,MGC_AGC_SEL, Node2_MGC_AGC_Select);
96
97%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98% 0.1. Generate a vector of samples to transmit and send the samples to the
99% Warp board (Sample Frequency is 40MHz)
100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101% Prepare some data to be transmitted
102t = 0:(1/40e6):TxLength/40e6 - 1/40e6; %Create time vector.
103% Create a signal to transmit, the signal can be real or complex.
104% The signal must meet the following requirements:
105% - Signal to transmit must be a row vector.
106% - The amplitude of the real part must be in [-1:1] and the amplitude
107% of the imaginary part must be in [-1:1].
108% - Highest frequency component is limited to 9.5 MHz (signal bandwidth
109% is limited to 19 MHz)
110% - Lowest frequency component is limited to 30 kHz
111Node1_Radio2Radio3_TxData = exp(t*j*2*pi*1e6);
112
113% Download the samples to be transmitted to Tx radio 2 buffer
114warplab_writeSMWO(udp_node1, RADIO2_TXDATA, Node1_Radio2Radio3_TxData);
115
116% Download the samples to be transmitted to Tx radio 3 buffer
117warplab_writeSMWO(udp_node1, RADIO3_TXDATA, Node1_Radio2Radio3_TxData);
118
119%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120% 0.2 Prepare boards for transmission from Tx radio 2 and reception on
121% both receiver antennas. Send trigger to start transmission and reception
122% (trigger is the SYNC packet)
123%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124% The following lines of code set node 1 as transmitter and node 2 as
125% receiver; transmission and capture are triggered by sending the SYNC
126% packet.
127
128% Enable transmitter radio path in radio 2 in node 1 (enable radio 2
129% in node 1 as transmitter)
130warplab_sendCmd(udp_node1, RADIO2_TXEN, packetNum);
131
132% Enable transmission of node1's radio 2 Tx buffer (enable
133% transmission of samples stored in radio 2 Tx Buffer in node 1)
134warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXEN, packetNum);
135
136% Enable receiver radio path in radios 2 and 3 in node 2 (enable radios 2
137% and 3 in node 2 as receivers)
138warplab_sendCmd(udp_node2, [RADIO2_RXEN, RADIO3_RXEN], packetNum);
139
140% Enable capture in node2's radio 2 and radio 3 Rx Buffer (enable radio 2
141% Rx buffer and radio 3 Rx buffer in node 2 for storage of samples)
142warplab_sendCmd(udp_node2, [RADIO2RXBUFF_RXEN, RADIO3RXBUFF_RXEN], packetNum);
143
144% Prime transmitter state machine in node 1. Node 1 will be
145% waiting for the SYNC packet. Transmission from node 1 will be triggered
146% when node 1 receives the SYNC packet.
147warplab_sendCmd(udp_node1, TX_START, packetNum);
148
149% Prime receiver state machine in node 2. Node 2 will be waiting
150% for the SYNC packet. Capture at node 2 will be triggered when node 2
151% receives the SYNC packet.
152warplab_sendCmd(udp_node2, RX_START, packetNum);
153
154% Send the SYNC packet
155warplab_sendSync(udp_Sync);
156
157%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158% 0.3 Read the received smaples from the WARP board
159%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160% Read back the received samples from radio 2
161[Node1_Radio2_to_Node2_Radio2_RawRxData] = warplab_readSMRO(udp_node2, RADIO2_RXDATA, TxLength+TxDelay);
162% Read back the received samples from radio 3
163[Node1_Radio2_to_Node2_Radio3_RawRxData] = warplab_readSMRO(udp_node2, RADIO3_RXDATA, TxLength+TxDelay);
164% Process the received samples to obtain meaningful data
165[Node1_Radio2_to_Node2_Radio2_RxData,Node1_Radio2_to_Node2_Radio2_RxOTR] = warplab_processRawRxData(Node1_Radio2_to_Node2_Radio2_RawRxData);
166[Node1_Radio2_to_Node2_Radio3_RxData,Node1_Radio2_to_Node2_Radio3_RxOTR] = warplab_processRawRxData(Node1_Radio2_to_Node2_Radio3_RawRxData);
167
168%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169% 0.4 Reset and disable the boards
170%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171% Set radio 2 Tx buffer in node 1 back to Tx disabled mode
172warplab_sendCmd(udp_node1, RADIO2TXBUFF_TXDIS, packetNum);
173
174% Disable the transmitter radio 2
175warplab_sendCmd(udp_node1, RADIO2_TXDIS, packetNum);
176
177% Let the receiver know that samples have been read and system is ready for
178% a new capture
179warplab_sendCmd(udp_node2, RX_DONEREADING, packetNum);
180
181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182% 0.5 Prepare WARP boards for transmission from Tx radio 3 and reception on
183% both receiver antennas. Send trigger to start transmission and reception
184% (trigger is the SYNC packet)
185%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186% The following lines of code set node 1 as transmitter and node 2 as
187% receiver; transmission and capture are triggered by sending the SYNC
188% packet.
189
190% Enable transmitter radio path in radio 3 in node 1 (enable radio 3
191% in node 1 as transmitter)
192warplab_sendCmd(udp_node1, RADIO3_TXEN, packetNum);
193
194% Enable transmission of node1's radio 3 Tx buffer (enable
195% transmission of samples stored in radio 3 Tx Buffer in node 1)
196warplab_sendCmd(udp_node1, RADIO3TXBUFF_TXEN, packetNum);
197
198% Notice receive radios in node 2 are still enabled so there is no need to
199% enable them again
200
201% Prime transmitter state machine in transmitter node. Transmitter will be
202% waiting for the SYNC packet. Transmission will be triggered when the
203% transmitter node receives the SYNC packet.
204warplab_sendCmd(udp_node1, TX_START, packetNum);
205
206% Prime receiver state machine in receiver node. Receiver will be waiting
207% for the SYNC packet. Capture will be triggered when the receiver
208% node receives the SYNC packet.
209warplab_sendCmd(udp_node2, RX_START, packetNum);
210
211% Send the SYNC packet
212warplab_sendSync(udp_Sync);
213
214
215%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216% 0.6 Read the received smaples from the Warp board
217%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218% Read back the received samples from radio 2
219[Node1_Radio3_to_Node2_Radio2_RawRxData] = warplab_readSMRO(udp_node2, RADIO2_RXDATA, TxLength+TxDelay);
220% Read back the received samples from radio 3
221[Node1_Radio3_to_Node2_Radio3_RawRxData] = warplab_readSMRO(udp_node2, RADIO3_RXDATA, TxLength+TxDelay);
222% Process the received samples to obtain meaningful data
223[Node1_Radio3_to_Node2_Radio2_RxData,Node1_Radio2_to_Node2_Radio2_RxOTR] = warplab_processRawRxData(Node1_Radio3_to_Node2_Radio2_RawRxData);
224[Node1_Radio3_to_Node2_Radio3_RxData,Node1_Radio2_to_Node2_Radio3_RxOTR] = warplab_processRawRxData(Node1_Radio3_to_Node2_Radio3_RawRxData);
225
226%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
227% 0.7 Reset and disable the boards
228%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229% Set radio 3 Tx buffer in node 1 back to Tx disabled mode
230warplab_sendCmd(udp_node1, RADIO3TXBUFF_TXDIS, packetNum);
231
232% Disable the transmitter radio 3
233warplab_sendCmd(udp_node1, RADIO3_TXDIS, packetNum);
234
235% Set radios 2 and 3 Rx buffer in node 2 back to Rx disabled mode
236warplab_sendCmd(udp_node2, [RADIO2RXBUFF_RXDIS, RADIO3RXBUFF_RXDIS], packetNum);
237
238% Disable the receiver radios
239warplab_sendCmd(udp_node2, [RADIO2_RXDIS,RADIO3_RXDIS], packetNum);
240
241% Close sockets
242pnet('closeall');
243
244
245%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246% 0.8 Plot the transmitted and received data
247%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248figure;
249subplot(5,2,1);
250plot(real(Node1_Radio2Radio3_TxData));
251title('Tx Node 1 Radio 2 I and Tx Node 1 Radio 3 I');
252xlabel('n (samples)'); ylabel('Amplitude');
253axis([0 2^14 -1 1]); % Set axis ranges.
254subplot(5,2,2);
255plot(imag(Node1_Radio2Radio3_TxData));
256title('Tx Node 1 Radio 2 Q and Tx Node 1 Radio 3 Q ');
257xlabel('n (samples)'); ylabel('Amplitude');
258axis([0 2^14 -1 1]); % Set axis ranges.
259subplot(5,2,3);
260plot(real(Node1_Radio2_to_Node2_Radio2_RxData));
261title('Rx Node 2 Radio 2 I when Node 1 Radio 2 was transmitting');
262xlabel('n (samples)'); ylabel('Amplitude');
263axis([0 2^14 -1 1]); % Set axis ranges.
264subplot(5,2,4);
265plot(imag(Node1_Radio2_to_Node2_Radio2_RxData));
266title('Rx Node 2 Radio 2 Q when Node 1 Radio 2 was transmitting');
267xlabel('n (samples)'); ylabel('Amplitude');
268axis([0 2^14 -1 1]); % Set axis ranges.
269subplot(5,2,5);
270plot(real(Node1_Radio2_to_Node2_Radio3_RxData));
271title('Rx Node 2 Radio 3 I when Node 1 Radio 2 was transmitting');
272xlabel('n (samples)'); ylabel('Amplitude');
273axis([0 2^14 -1 1]); % Set axis ranges.
274subplot(5,2,6);
275plot(imag(Node1_Radio2_to_Node2_Radio3_RxData));
276title('Rx Node 2 Radio 3 Q when Node 1 Radio 2 was transmitting');
277xlabel('n (samples)'); ylabel('Amplitude');
278axis([0 2^14 -1 1]); % Set axis ranges.
279subplot(5,2,7);
280plot(real(Node1_Radio3_to_Node2_Radio2_RxData));
281title('Rx Node 2 Radio 2 I when Node 1 Radio 3 was transmitting');
282xlabel('n (samples)'); ylabel('Amplitude');
283axis([0 2^14 -1 1]); % Set axis ranges.
284subplot(5,2,8);
285plot(imag(Node1_Radio3_to_Node2_Radio2_RxData));
286title('Rx Node 2 Radio 2 Q when Node 1 Radio 3 was transmitting');
287xlabel('n (samples)'); ylabel('Amplitude');
288axis([0 2^14 -1 1]); % Set axis ranges.
289subplot(5,2,9);
290plot(real(Node1_Radio3_to_Node2_Radio3_RxData));
291title('Rx Node2 Radio 3 I when Node 1 Radio 3 was transmitting');
292xlabel('n (samples)'); ylabel('Amplitude');
293axis([0 2^14 -1 1]); % Set axis ranges.
294subplot(5,2,10);
295plot(imag(Node1_Radio3_to_Node2_Radio3_RxData));
296title('Rx Node 2 Radio 3 Q when Node 1 Radio 3 was transmitting');
297xlabel('n (samples)'); ylabel('Amplitude');
298axis([0 2^14 -1 1]); % Set axis ranges.
299
300%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301% 1. Remove from the received vector the samples that do not correspond to
302% transmitted data. In other words, remove from the received vector samples
303% 1 to TxDelay. This step will remove samples that correspond to measured
304% noise and make the RxData vector the same length as the TxData vector
305%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306Tx2_Rx2_RxData = Node1_Radio2_to_Node2_Radio2_RxData(TxDelay+1:end);
307Tx2_Rx3_RxData = Node1_Radio2_to_Node2_Radio3_RxData(TxDelay+1:end);
308Tx3_Rx2_RxData = Node1_Radio3_to_Node2_Radio2_RxData(TxDelay+1:end);
309Tx3_Rx3_RxData = Node1_Radio3_to_Node2_Radio3_RxData(TxDelay+1:end);
310
311%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312% 2. Compute the amplitude and the phase of the transmitted and received
313% sammples
314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315% Compute the magnitude per sample of the transmitted and received
316% data
317mag_TxData = abs(Node1_Radio2Radio3_TxData); % Tx data
318mag_Tx2_Rx2_RxData = abs(Tx2_Rx2_RxData); 
319mag_Tx2_Rx3_RxData = abs(Tx2_Rx3_RxData);
320mag_Tx3_Rx2_RxData = abs(Tx3_Rx2_RxData);
321mag_Tx3_Rx3_RxData = abs(Tx3_Rx3_RxData);
322
323% Compute the phase per sample of the transmitted data
324phase_TxData = angle(Node1_Radio2Radio3_TxData);
325phase_TxData_unw = unwrap(phase_TxData);
326phase_TxData = phase_TxData *180/pi; %Convert to degrees
327phase_TxData_unw = phase_TxData_unw *180/pi; %Convert to degrees
328
329phase_Tx2_Rx2_RxData = angle(Tx2_Rx2_RxData);
330phase_Tx2_Rx2_RxData_unw = unwrap(phase_Tx2_Rx2_RxData);
331phase_Tx2_Rx2_RxData = phase_Tx2_Rx2_RxData *180/pi; %Convert to degrees
332phase_Tx2_Rx2_RxData_unw = phase_Tx2_Rx2_RxData_unw *180/pi; %Convert to degrees
333
334phase_Tx2_Rx3_RxData = angle(Tx2_Rx3_RxData);
335phase_Tx2_Rx3_RxData_unw = unwrap(phase_Tx2_Rx3_RxData);
336phase_Tx2_Rx3_RxData = phase_Tx2_Rx3_RxData *180/pi; %Convert to degrees
337phase_Tx2_Rx3_RxData_unw = phase_Tx2_Rx3_RxData_unw *180/pi; %Convert to degrees
338
339phase_Tx3_Rx2_RxData = angle(Tx3_Rx2_RxData);
340phase_Tx3_Rx2_RxData_unw = unwrap(phase_Tx3_Rx2_RxData);
341phase_Tx3_Rx2_RxData = phase_Tx3_Rx2_RxData *180/pi; %Convert to degrees
342phase_Tx3_Rx2_RxData_unw = phase_Tx3_Rx2_RxData_unw *180/pi; %Convert to degrees
343
344phase_Tx3_Rx3_RxData = angle(Tx3_Rx3_RxData);
345phase_Tx3_Rx3_RxData_unw = unwrap(phase_Tx3_Rx3_RxData);
346phase_Tx3_Rx3_RxData = phase_Tx3_Rx3_RxData *180/pi; %Convert to degrees
347phase_Tx3_Rx3_RxData_unw = phase_Tx3_Rx3_RxData_unw *180/pi; %Convert to degrees
348
349% Plot magnitude and phase of transmitted and received samples
350figure;
351subplot(5,2,1);
352plot(mag_TxData);
353title('Tx Node 1 Radio 2 magnitude and Tx Node 1 Radio 3 magnitude ');
354xlabel('n (samples)'); ylabel('Amplitude');
355subplot(5,2,2);
356plot(phase_TxData_unw);
357title('Tx Node 1 Radio 2 phase and Tx Node 1 Radio 3 phase ');
358xlabel('n (samples)'); ylabel('Amplitude');
359subplot(5,2,3);
360plot(mag_Tx2_Rx2_RxData);
361title('Rx Node 2 Radio 2 magnitude when Node 1 Radio 2 was transmitting');
362xlabel('n (samples)'); ylabel('Amplitude');
363subplot(5,2,4);
364plot(phase_Tx2_Rx2_RxData_unw);
365title('Rx Node 2 Radio 2 phase when Node 1 Radio 2 was transmitting');
366xlabel('n (samples)'); ylabel('Amplitude');
367subplot(5,2,5);
368plot(mag_Tx2_Rx3_RxData);
369title('Rx Node 2 Radio 3 magnitude when Node 1 Radio 2 was transmitting');
370xlabel('n (samples)'); ylabel('Amplitude');
371subplot(5,2,6);
372plot(phase_Tx2_Rx3_RxData_unw);
373title('Rx Node 2 Radio 3 phase when Node 1 Radio 2 was transmitting');
374xlabel('n (samples)'); ylabel('Amplitude');
375subplot(5,2,7);
376plot(mag_Tx3_Rx2_RxData);
377title('Rx Node 2 Radio 2 magnitude when Node 1 Radio 3 was transmitting');
378xlabel('n (samples)'); ylabel('Amplitude');
379subplot(5,2,8);
380plot(phase_Tx3_Rx2_RxData_unw);
381title('Rx Node 2 Radio 2 phase when Node 1 Radio 3 was transmitting');
382xlabel('n (samples)'); ylabel('Amplitude');
383subplot(5,2,9);
384plot(mag_Tx3_Rx3_RxData);
385title('Rx Node 2 Radio 3 magnitude when Node 1 Radio 3 was transmitting');
386xlabel('n (samples)'); ylabel('Amplitude');
387subplot(5,2,10);
388plot(phase_Tx3_Rx3_RxData_unw);
389title('Rx Node 2 Radio 3 phase when Node 1 Radio 3 was transmitting');
390xlabel('n (samples)'); ylabel('Amplitude');
391
392% Plot magnitude and phase of transmitted and received samples
393
394%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395% 3. Compute the channel amplitude and channel phase per sample
396%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
397% Compute the channel amplitudes
398channel_amplitude_Tx2_Rx2 = mag_Tx2_Rx2_RxData./mag_TxData;
399channel_amplitude_Tx2_Rx3 = mag_Tx2_Rx3_RxData./mag_TxData;
400channel_amplitude_Tx3_Rx2 = mag_Tx3_Rx2_RxData./mag_TxData;
401channel_amplitude_Tx3_Rx3 = mag_Tx3_Rx3_RxData./mag_TxData;
402
403% Compute the channel phases
404channel_phase_Tx2_Rx2 = phase_Tx2_Rx2_RxData_unw - phase_TxData_unw;
405channel_phase_Tx2_Rx3 = phase_Tx2_Rx3_RxData_unw - phase_TxData_unw;
406channel_phase_Tx3_Rx2 = phase_Tx3_Rx2_RxData_unw - phase_TxData_unw;
407channel_phase_Tx3_Rx3 = phase_Tx3_Rx3_RxData_unw - phase_TxData_unw;
408
409% Plot channel amplitude
410figure
411subplot(2,2,1)
412plot(channel_amplitude_Tx2_Rx2)
413title('Node1Radio2-Node2Radio2 path - Channel Amplitude per sample')
414xlabel('n (samples)'); ylabel('Amplitude');
415subplot(2,2,2)
416plot(channel_amplitude_Tx2_Rx3)
417title('Node1Radio2-Node2Radio3 path - Channel Amplitude per sample')
418xlabel('n (samples)'); ylabel('Amplitude');
419subplot(2,2,3)
420plot(channel_amplitude_Tx3_Rx2)
421title('Node1Radio3-Node2Radio2 path - Channel Amplitude per sample')
422xlabel('n (samples)'); ylabel('Amplitude');
423subplot(2,2,4)
424plot(channel_amplitude_Tx3_Rx3)
425title('Node1Radio3-Node2Radio3 path - Channel Amplitude per sample')
426xlabel('n (samples)'); ylabel('Amplitude');
427
428%Plot channel phase
429figure
430subplot(2,2,1)
431plot(channel_phase_Tx2_Rx2)
432xlabel('n (samples)'); ylabel('Degrees');
433title('Node1Radio2-Node2Radio2 path - Channel Phase per sample')
434subplot(2,2,2)
435plot(channel_phase_Tx2_Rx3)
436xlabel('n (samples)'); ylabel('Degrees');
437title('Node1Radio2-Node2Radio3 path - Channel Phase per sample')
438subplot(2,2,3)
439plot(channel_phase_Tx3_Rx2)
440xlabel('n (samples)'); ylabel('Degrees');
441title('Node1Radio3-Node2Radio2 path - Channel Phase per sample')
442subplot(2,2,4)
443plot(channel_phase_Tx3_Rx3)
444xlabel('n (samples)'); ylabel('Degrees');
445title('Node1Radio3-Node2Radio3 path - Channel Phase per sample')
446
Note: See TracBrowser for help on using the repository browser.