From f397e7fd440fefdd52237c800fc05f46a144d2f8 Mon Sep 17 00:00:00 2001
From: Erik Kooistra <kooistra@astron.nl>
Date: Mon, 17 Oct 2016 15:13:05 +0000
Subject: [PATCH] Corrected title in subband phase plot. Use subplot for real()
 and imag() in subband plot.

---
 applications/apertif/matlab/run_pfb_complex.m | 33 +++++++++++++++++--
 .../apertif/matlab/run_pfft_complex.m         | 24 ++++++++++----
 2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/applications/apertif/matlab/run_pfb_complex.m b/applications/apertif/matlab/run_pfb_complex.m
index 9da80b9e50..60491ec329 100644
--- a/applications/apertif/matlab/run_pfb_complex.m
+++ b/applications/apertif/matlab/run_pfb_complex.m
@@ -48,7 +48,7 @@ tb.model_signal = 'phasor';            % Use phasor to check the frequency respo
 
 tb.model_quantization = 'floating point';
 tb.model_quantization = 'fixed point';
-tb.nof_channels = 32;
+tb.nof_channels = 64;
 
 % Carrier frequency
 tb.channel_wg        = 1;           % channel range -tb.nof_channels/2:tb.nof_channels/2-1, can be fraction to have any sinusoid frequency
@@ -60,7 +60,7 @@ tb.sop               = 1;           % initial 'impulse' start index in range ctr
 
 % Model a frequency sweep of the 'sinusoid'
 tb.chirp             = 0;              % 0 = use fixed tb.channel_wg frequency or pulse period equal to block_size
-%tb.chirp             = 1;              % else increment WG frequency every block to have chirp frequency sweep or slide the pulse
+tb.chirp             = 1;              % else increment WG frequency every block to have chirp frequency sweep or slide the pulse
 if strcmp(tb.model_signal, 'noise')
     tb.nof_tchan      = 50;            % number of channel periods to simulate, >> ctrl_pfir_channel.nof_taps
 elseif tb.chirp
@@ -394,6 +394,31 @@ xlabel(sprintf('Time 0:%d [Tchan]', tb.nof_tchan-1));
 ylabel('Voltage');
 grid on;
 
+%% Plot PFFT channels real and imaginary for all tb.nof_tchan in one plot
+data = data_pfft_channel.';
+data = data(:);
+hy = 1.2 * max(abs(data));
+
+fig=fig+1;
+figure('position', [xfig+fig*dfig yfig-fig*dfig xfigw yfigw]);
+figure(fig);
+
+subplot(2,1,1);
+plot(tchan_all, real(data), 'k', tchan_all(chan_I), real(data(chan_I)), 'ko', tchan_all(chan_Iplus1), real(data(chan_Iplus1)), 'kx');
+ylim([-hy hy])
+title(sprintf('Channel real data (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
+ylabel('Voltage');
+grid on;
+
+subplot(2,1,2);
+plot(tchan_all, imag(data), 'k', tchan_all(chan_I), imag(data(chan_I)), 'ko', tchan_all(chan_Iplus1), imag(data(chan_Iplus1)), 'kx');
+ylim([-hy hy])
+title(sprintf('Channel imag data (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
+ylabel('Voltage');
+grid on;
+
 %% Plot PFFT channels spectrum and phase for all tb.nof_tchan in one plot
 chan_ampl = abs(data_pfft_channel);
 chan_ampl_max = max(chan_ampl(:));
@@ -404,6 +429,7 @@ chan_phase(x) = 0;   % force phase of too small signals to 0
 fig=fig+1;
 figure('position', [xfig+fig*dfig yfig-fig*dfig xfigw yfigw]);
 figure(fig);
+
 subplot(2,1,1);
 data = chan_ampl.';
 data = data(:);
@@ -412,12 +438,13 @@ title(sprintf('Channel data - amplitude  (o,x = channel %d,%d for WG channel = %
 xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
 ylabel('Voltage');
 grid on;
+
 subplot(2,1,2);
 data = chan_phase.';
 data = data(:);
 plot(tchan_all, data, 'k', tchan_all(chan_I), data(chan_I), 'ko', tchan_all(chan_Iplus1), data(chan_Iplus1), 'kx');
 ylim([-180 180])
-title(sprintf('Channel data - amplitude  (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+title(sprintf('Channel data - phase  (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
 xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
 ylabel('Phase [degrees]');
 grid on;
diff --git a/applications/apertif/matlab/run_pfft_complex.m b/applications/apertif/matlab/run_pfft_complex.m
index aa9029b084..079f645dfb 100644
--- a/applications/apertif/matlab/run_pfft_complex.m
+++ b/applications/apertif/matlab/run_pfft_complex.m
@@ -257,16 +257,26 @@ ylabel('Voltage');
 grid on;
 
 %% Plot PFFT channels real and imaginary for all tb.nof_tchan in one plot
+data = data_pfft_channel.';
+data = data(:);
+hy = 1.2 * max(abs(data));
+
 fig=fig+1;
 figure('position', [xfig+fig*dfig yfig-fig*dfig xfigw yfigw]);
 figure(fig);
 
-data = data_pfft_channel.';
-data = data(:);
-hy = 1.2 * max(abs(data));
-plot(tchan_all, real(data), 'r', tchan_all, imag(data), 'b');
+subplot(2,1,1);
+plot(tchan_all, real(data), 'k', tchan_all(chan_I), real(data(chan_I)), 'ko', tchan_all(chan_Iplus1), real(data(chan_Iplus1)), 'kx');
 ylim([-hy hy])
-title(sprintf('Channel real and imag data (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+title(sprintf('Channel real data (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
+ylabel('Voltage');
+grid on;
+
+subplot(2,1,2);
+plot(tchan_all, imag(data), 'k', tchan_all(chan_I), imag(data(chan_I)), 'ko', tchan_all(chan_Iplus1), imag(data(chan_Iplus1)), 'kx');
+ylim([-hy hy])
+title(sprintf('Channel imag data (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
 xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
 ylabel('Voltage');
 grid on;
@@ -281,6 +291,7 @@ chan_phase(x) = 0;   % force phase of too small signals to 0
 fig=fig+1;
 figure('position', [xfig+fig*dfig yfig-fig*dfig xfigw yfigw]);
 figure(fig);
+
 subplot(2,1,1);
 data = chan_ampl.';
 data = data(:);
@@ -289,12 +300,13 @@ title(sprintf('Channel data - amplitude  (o,x = channel %d,%d for WG channel = %
 xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
 ylabel('Voltage');
 grid on;
+
 subplot(2,1,2);
 data = chan_phase.';
 data = data(:);
 plot(tchan_all, data, 'k', tchan_all(chan_I), data(chan_I), 'ko', tchan_all(chan_Iplus1), data(chan_Iplus1), 'kx');
 ylim([-180 180])
-title(sprintf('Channel data - amplitude  (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
+title(sprintf('Channel data - phase  (o,x = channel %d,%d for WG channel = %6.3f)', tb.channel_i, tb.channel_iplus1, tb.channel_wg));
 xlabel(sprintf('Channels 0:%d at time 0:%d [Tchan]', tb.nof_channels-1, tb.nof_tchan-1));
 ylabel('Phase [degrees]');
 grid on;
-- 
GitLab