Help with plotting

Part I Basic Plotting The RC circuit shown below forms a low pass filter. The transfer function of this filter is given as
Vout / Vin = (1 + j?RC ) -1
Picture here of simple Capacitor Circuit R=50Ohms and C=1.0*10^-9 Farads
Plot the transfer function over a frequency range from 10 kHz to 10 MHz.
Case A. Use a linearly spaced frequency vector.
  • Add labels to the x- and y-axis; include units here!
  • Add a title to the figure.
  • Add a horizontal line at the value Vout/Vin = 0.5.
  • Add an arrow pointing to the intersection of the two lines, insert text near the arrow to explain.
  • Turn the grid on.
  • Adjust all line widths and text sizes to make them easily visible.
  • Collect these commands into a “dot M” file.
  • Execute the file to produce the plot, submit the plot with your report.
I have developed this incoplete code Answered a certain amount of the problem but my problem is my plot errors in which I do not know how to fix.
x = linspace(10000, 10000000);
w=2*pi*x;
c=1.0*10^-9;
r=50;
y=(1+i*w*c*r).^-1
plot(x,y);
title( 'Case A' );
xlabel( ' Linearly Spaced Frequency Domain' );
ylabel( ' V_in / V_out' );
grid on;
Also I need to learn how to do a vertical line and text arrow but the plot is the most important first.

Answers (2)

Walter Roberson
Walter Roberson on 20 Jan 2011
Your formula for y involves constructing complex numbers and taking their reciprocal. The result for non-zero x is always going to be complex (otherwise there would have to be a real number whose reciprocal was a complex number.) Thus your y is going to be mostly complex. You cannot use plot(x,y) to plot a complex y.
You will need to decide what you want to plot. You might want to plot real(y) or imag(y) or abs(y).
If what you want is a 3D plot with the real y on one axis and the imaginary y on another axis, then you would use
plot3(x, real(y), imag(y))
Sean de Wolski
Sean de Wolski on 20 Jan 2011
help annotation
help line
help grid
a few hints...

Products

Asked:

on 20 Jan 2011

Community Treasure Hunt

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

Start Hunting!