Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help in MATLAB. I'm working on a circuits lab report and I want to plot the derivative of an input signal. The circuit

I need help in MATLAB. I'm working on a circuits lab report and I want to plot the derivative of an input signal. The circuit is a differentiator OpAmp. It is receiving a triangle wave as an input and should output a square wave. (I've included my existing code.)

The output formula is:

Vout = -(Rf)*C*(dVin/dt) Where Rf is feedback resistance: Rf = 1*10^6; and C = 1*10^-6.

EXISTING CODE:

%% This section is copied, and then modified from another problem for use as the input.

%%Does not need to be changed.

clc

clear all

close all

R1 = 1000;

C1 = (1*10^-3);

t = linspace(0,20);

In1 = square(t);

f=@(t) [2*[(-1/(R1*C1))*(integral(@(t) square(t),0,t))]/(3)]+1;

for i=1:numel(t)

Vo1(i) = f(t(i));

end

%% Setting up new circuit values.

Rf = 1*10^6;

C2 = 1*10^-6;

%% Now I need to use the outut of the modified previous problem as input.

% Vout = -(R_feedback)*C*[d(Vin)/dt] *Again Vin here, is Vo1 from

% the previous problem.*

%

%% I originally thought this was where my mistake was, however I believe its actually in the subplot.

% My answers for Vo2 in the array are oscillating the way a square wave does, but it doesn't plot properly.

Vo2 = -Rf*C2*diff(Vo1)

%% Plotting outputs.

subplot(2,1,1)

plot(t/pi,Vo1,'r.-')

title('Input Voltage')

xlabel('t')

ylabel('V(t)')

xlim([0 5])

ylim([-1.5, 1.5])

grid on

subplot(2,1,2)

plot(t/pi,Vo2,'g.-')

title('Inverted Output Voltage')

xlabel('t')

ylabel('V(t)')

xlim([0 5])

grid on

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

Prepare an electronic rsum.

Answered: 1 week ago

Question

Strengthen your personal presence.

Answered: 1 week ago

Question

Identify the steps to follow in preparing an oral presentation.

Answered: 1 week ago