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 Center および File ExchangeWaveform Generation についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by