?? genrect.asv
字號:
%
% FUNCTION 1.1 : "cp0101_genrect"
%
% Generates a unitary amplitude rectangular waveform
% which is modulated by a sinusoid at frequency 'f0'
% 'signal' is the output waveform
% 'dt' is the sampling period
%
% Programmed by Guerino Giancola
%
function [signal,dt] = cp0101_genrect
% ----------------------------
% Step Zero - Input parameters
% ----------------------------
width = 1e-1; % width of the rectangle [s] ,the time duration of the rectangular waveform
points = 1000; % number of samples for representing the rectangle
f0 = 1e3; % carrier frequency [Hz]
% ----------------------------
% Step One - Output evaluation
% ----------------------------
dt = width / points; % sampling period
signal = zeros(1,5*points);%first ,set 0 to the interval [0,5000]
signal(2*points:3*points-1)=ones(1,points);
mod=cos(2.*pi.*f0.*linspace(0,5*width,5*points));%Modulation signal
%linspace(1,5*width,5*points) divide 5*points in the interval [1,0.5]
signal=signal.*mod; % the Modulated signal
% ---------------------------
% Step Two - Graphical Output
% ---------------------------
figure(1)
%time=linspace(-2*width,3*width,5*points); % field of the Xlabel [-0.2,0.3] ,and 5000 points must samples
time=linspace(0,0.045,5*points);
signal1=signal();
P1=plot(time,signal,'r');
% Set the LineWidth of the figure
set(P1,'LineWidth',[2]);
%axis([-2*width 3*width -1.2 1.2]);
% Get handle to current axis
AX=gca;
set(AX,'FontSize',12);
X=xlabel('Time [s]');
set(X,'FontSize',14);
Y=ylabel('Amplitude [V]');
set(Y,'FontSize',14);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -