Search code examples
matlabplotvectorizationmatlab-figure

plot function not displaying results of division of two vectors


I am attempting to plot percent overshoot as a function of the damping ratio.

The damping ratio range: 0 to 1

Here's what I have:

dr = (0:0.1:1);                    % Damping Ratio
PO = exp((-pi*dr)/sqrt(1 - (dr.^2))); % Percent Overshoot Function
plot(dr, PO)                          % Plot Function**

Here is what I get: Picture of generated plot with no lines. Correct Bounds.

I know that the issue is with the square root component. When I remove the variable from the square root, the function plots. Not sure why.. please help.


Solution

  • For element-by-element vector arithmetic use ./, .*, .^ operators. The problem with your code is that you used /(right-matrix division) for division. Use ./ (Right array division) instead. Here is a description about what matrix division operators do.