Oganize preload and init functions and parameters (ongoing)

This commit is contained in:
canisio
2026-04-04 15:16:58 -03:00
parent 040834d511
commit eb14676581
40 changed files with 133 additions and 105 deletions

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