Skip to content

Commit

Permalink
Fix save figure API in AD9081 tests
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed Aug 18, 2023
1 parent 7108abf commit 7e52970
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 16 additions & 2 deletions test/AD9081HWTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions test/runHWTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7e52970

Please sign in to comment.