Varying an Input to an Amplifier Model

조회 수: 1 (최근 30일)
Daniel Clayton
Daniel Clayton 2020년 12월 14일
답변: Mathieu NOE 2020년 12월 14일
Hello
I have written some Matlab code to describe the behaviour of a specific type of amplifier when supplied with two input signals out of phase with each other. In this code I have a set gain value (G) and a set amplitude value (A) and I am able to plot the result of this without any problem.
I would now like to plot the output with the input amplitude varying from -pi to +pi but when I try this, it results in the matrix dimensions not agreeing and was wondering if there is a simple way to resolve this? Below is the code I have written:
f1 = 100000; %input signal 1 frequency
f2 = 200000; %input signal 2 frequency
fs = 50*f1; %sampling frequency
Ta = 1/f1; %input frequency period
Ts = 1/fs; %sampling frequency period
t = (0:Ts:50*Ta); %timing and step size
A = (-pi:pi); %Fixed amplitude value
G = 10; %Gain of amplifiers
S1 = cos(2*pi*f1*t + acos(A)); %Input signal 1
S2 = cos(2*pi*f2*t - acos(A)); %Input signal 2
Sout = G*(S1+S2); %Combined output signal
plot (Sout);
Any help with this would be much appreciated.
Regards
Dan

답변 (1개)

Mathieu NOE
Mathieu NOE 2020년 12월 14일
hello
you have to make A and t the same size to make it work
so this is it :
f1 = 100000; %input signal 1 frequency
f2 = 200000; %input signal 2 frequency
fs = 50*f1; %sampling frequency
Ta = 1/f1; %input frequency period
Ts = 1/fs; %sampling frequency period
t = (0:Ts:50*Ta); %timing and step size
A = linspace(-pi,pi,length(t)); %Fixed amplitude value
G = 10; %Gain of amplifiers
S1 = cos(2*pi*f1*t + acos(A)); %Input signal 1
S2 = cos(2*pi*f2*t - acos(A)); %Input signal 2
Sout = G*(S1+S2); %Combined output signal
plot (Sout);

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by