Varying an Input to an Amplifier Model

4 views (last 30 days)
Daniel Clayton
Daniel Clayton on 14 Dec 2020
Answered: Mathieu NOE on 14 Dec 2020
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

Answers (1)

Mathieu NOE
Mathieu NOE on 14 Dec 2020
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);

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!