- Added utilities for frequency planning

- Changed freq plane to: Fs 4096, int/dec 8X, Mixers 768
This commit is contained in:
canisio
2026-03-27 12:50:10 -03:00
parent d5bbdfb435
commit 584db6233c
22 changed files with 838 additions and 0 deletions

58
utilities/plotspectrum.m Normal file
View File

@@ -0,0 +1,58 @@
function h = plotspectrum(type, centers, bandwidth, color, unit, varargin)
for n = 1:numel(centers)
center = centers(n);
switch type
case 'sym'
x = [-1, -1, 0, 1, 1] * (bandwidth/2) + center;
y = [ 0, 0.5, 1, 0.5, 0];
case 'asym'
x = [-1, -1, 1, 1] * (bandwidth/2) + center;
y = [0, 0.5, 1, 0];
case 'asymflip'
x = [-1, -1, 1, 1] * (bandwidth/2) + center;
y = [0, 1, 0.5, 0];
otherwise
error('Invalid type.');
end
switch unit
case 'Hz'
factor = 1;
case 'kHz'
factor = 1e3;
case 'MHz'
factor = 1e6;
case 'GHz'
factor = 1e9;
otherwise
error('Invalid unit');
end
tmp = patch(x/factor, y, color, varargin{:});
if n == 1
h = tmp;
else
h = [h, tmp]; %#ok<AGROW>
end
end
switch unit
case 'Hz'
xlabel('Frequency (Hz)', 'FontWeight', 'bold')
case 'kHz'
xlabel('Frequency (kHz)', 'FontWeight', 'bold')
case 'MHz'
xlabel('Frequency (MHz)', 'FontWeight', 'bold')
case 'GHz'
xlabel('Frequency (GHz)', 'FontWeight', 'bold')
otherwise
error('Invalid unit');
end
a = gca;
a.XAxis.FontWeight = 'bold';
end