From 7e5297028ff11f424eaeaf6a9793d12ae91f1214 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Fri, 18 Aug 2023 09:09:14 -0600 Subject: [PATCH] Fix save figure API in AD9081 tests Signed-off-by: Travis F. Collins --- test/AD9081HWTests.m | 18 ++++++++++++++++-- test/runHWTests.m | 8 ++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index 3e98f92b..aa75b137 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -37,12 +37,26 @@ function estFrequency(data,fs,saveNoShow,figname) end end - function freq = estFrequencyMax(data,fs) + function freq = estFrequencyMax(data,fs,saveNoShow,figname) nSamp = length(data); FFTRxData = fftshift(10*log10(abs(fft(data)))); df = fs/nSamp; freqRangeRx = (0:df:fs/2-df).'; [~,ind] = max(FFTRxData(end-length(freqRangeRx)+1:end,:)); freq = freqRangeRx(ind); + if nargin < 3 + saveNoShow = false; + end + if nargin < 4 + figname = 'freq_plot'; + end + if saveNoShow + f = figure('visible','off'); + end + plot(freqRangeRx, FFTRxData(end-length(freqRangeRx)+1:end,:)); + if saveNoShow + saveas(f,figname,'png') + saveas(f,figname,'fig') + end end end @@ -203,7 +217,7 @@ function testAD9081RxWithTxData(testCase) rx.release(); % plot(real(out)); - freqEst = meanfreq(double(real(out)),sr,true,'OneChanData_Chan1'); + freqEst = meanfreq(double(real(out)),sr); testCase.verifyTrue(valid); testCase.verifyGreaterThan(sum(abs(double(out))),0); diff --git a/test/runHWTests.m b/test/runHWTests.m index 69db5d9e..cdcd6b35 100644 --- a/test/runHWTests.m +++ b/test/runHWTests.m @@ -62,10 +62,10 @@ function runHWTests(board) fclose(fid); catch e disp(getReport(e,'extended')); -% bdclose('all'); -% exit(1); + bdclose('all'); + exit(1); end save(['BSPTest_',datestr(now,'dd_mm_yyyy-HH_MM_SS'),'.mat'],'t'); -% bdclose('all'); -% exit(any([results.Failed])); + bdclose('all'); + exit(any([results.Failed])); end