# How do you sketch the amplitude response in MATLAB?

How do you plot the amplitude response

where:

$$Y=\dfrac{1}{\sqrt{R^2+\omega^2 L^2}}$$

That's it. I'm really struggling with symbolic math or converting it to a tf for bode plot and whenever I try to plot it, I'm not sure if I plotted it correctly with the equation I just get from thin air.

• Isn't that the amplitude right there since there is no j or s? Commented Oct 8, 2021 at 15:29
• A little hard to know if you've plotted it correctly unless you show us the plot Commented Oct 8, 2021 at 16:33
• bodemag
– Syed
Commented Oct 8, 2021 at 17:17
• Victor, write more. There's not enough here to read between the lines. And my crystal ball is also broken.
– jonk
Commented Oct 9, 2021 at 7:40

Plotting in MATLAB is typically not done symbolically. You need to do it the way you learned how to graph things in grade school: by evaluating the function at a few places and then connecting the dots.

Fortunately, you don't need to do the math by hand. Here's a basic example:

$$y = x^2 + 4$$

1. Evaluate the function at a few places: let's choose x = -2, -1, 0, 1, 2.
x y
-2 8
-1 5
0 4
1 5
2 8
1. Connect the dots.

Let's see some code that does this.

x = [-2:2];
y = x.^2+4;
plot(x,y);


Output:

You can see that MATLAB just draws lines between the data points, so if you want more resolution, you need more samples. For your equation, you can do the following:

w = logspace(0,8,1000);    % Creates a vector of 1000 points spaced logarithmically
Y = 1./sqrt(R^2+w.^2*L^2); % Calculates Y at every value of w.
semilogx(w,Y);             % Plots Y as a function of w on a log scale.