Notice that a diamond shape marker appears on top of the
root indicating that you can now move this root to a new location by dragging it with the mouse. Observe
that while you are dragging the root to a new location the top plot is being continuously updated to
reflect the transfer function magnitude and phase associated with the pole/zero plot. (This is the
signature feature of editz.) When you release the mouse button, the diamond marker will disappear but
will reappear as soon as you click on another root that you wish to move. Note that when you are moving
a root, you are actually moving a pair of roots (complex conjugate pairs) unless the root is on the x axis.
This ensures that the polynomial coefficients are always real.
Likewise, when you are moving either a zero or a pole, often you will want to place it on the real axis.
To make this easier, as you move the root inside the green tolerance band along the X axis, the root will
snap to the real axis. Note that as you snap a root onto the real axis, the number of coefficients in the
corresponding polynomial will decrease by one since the root no longer has a corresponding complex conjugate
location. (You will also see the number of zeros or poles change in the TraceID box just to the left of the
Yaxis label.) Note that as you are moving the root, the x/y cursor readout shows the real and imaginary
components of the root respectively and the polar representation (i.e. magnitude/phase) is shown in
parenthesis to the right of the x cursor readout - (0.743, 172.04 degrees) in this example.
To add a new pole or zero, click on the "new pole" or "new zero" button.
The new root will appear at (0,0) and then you can drag it to the desired location.
To remove a root, click on it and then click on the "delete p/z" button.
You can undo the delete operation by right clicking on the "delete p/z" button.
(This is a multi-level undo, so you can delete all the roots and then restore them all by continuing
to right click on the button.) Click on the "save" button to save the current transfer function.
(It will be stored in a file called editz.mat in the same folder as editz.m.) Click the "load" button
to restore the transfer function stored in the file. When you start editz, the initial transfer
function will be loaded from this file. If you want to start editz using the default transfer function
mentioned above, simply delete the editz.mat file.
The dark blue strip between the two plots shows the coefficients of the transfer function numerator
and denominator polynomials (num(z) and den(z)).
The highest-order term is on the left. You will see these coefficients change whenever you move roots
around using the pole/zero plot, add or remove roots, or hit one of the quantization buttons.
You can also edit these coefficients by typing in new values. Just right click on any coefficient,
backspace to remove the old value and type in a new value. When you press "enter", the new value will
be accepted and the transfer function and pole/zero plots will be updated to reflect the new transfer
function. You can also increase or decrease the coefficient value by a small amount (.001 by default)
by left clicking on it. If you click closer to the right edge of the number, the coefficient will
increase and if you click closer to the left edge it will decrease. It's also interesting to hold down
the mouse button while the mouse is over a coefficient. What will happen then is that the coefficient
will slowly increase or decrease, while you watch the roots move slowly in the lower plot, and the
magnitude and phase response changes in the upper plot. (You can adjust the update rate if you like.)
The text color for the coefficients alternates between purple and yellow every 5 values. (i.e. the first
5 are purple, the next 5 are yellow, then back to purple, etc.) This makes it easier to see at a glance
how many coefficients there are. There is only enough room to display the first 12 coefficients of each
polynomial with the default figure size, but if you add enough roots to go beyond that you can stretch
the figure width if you need to see all the coefficients.
While (or after) you are dragging a root of the transfer function in the pole/zero plot, the associated
polynomial is saved in its full precision (i.e. 64-bit floating point). Although only 5 decimal places
are displayed in the coefficient strip, the full precision is available in the base workspace variables
as well as in the editz.mat file if the save button is pressed. However, suppose we then click on
the "den quant: 100" with the mouse. (It doesn't matter whether you click on the number or the label.)
Then all the coefficients in the denominator polynomial will be rounded to two digits after the decimal
point. (i.e. a coefficient value of 1.6388 would be rounded to 1.64). But that's only the default
quantization. Suppose for example that you wanted to round the denominator coefficients to 4 digits
after the decimal point. To do this, right click on "den quant: 100" (either the number or the label),
then backspace to remove the "100" and then enter "10^4". Or suppose you want to round to 6 binary
digits after the binary point. Then you would enter "2^6".
This quantization feature has been included in editz because when a digital filter is realized
the filter coefficients will become quantized to a level that depends on the implementation. So it is
useful to get a feel for how this quantization affects the root locations and the frequency response.
Or to produce a step response using vertical bars,
replace the last line with this slightly more complex plt command:
plt xleft EDIT 5; % exit data editing mode
[t r] = cart2pol(real(z),imag(z)); % convert zeros to polar (theta,rho)
c = 36/pi; [x y] = pol2cart(round(c*t)/c,r); % round angle to nearest 5 degrees
h = getappdata(gcf,'Lhandles'); % list of lines [Mag Phase Zeros Poles Circle]
set(h(3),'x',x,'y',y); % save quantized data to the zeros line
a = get(gcf,'ResizeFcn'); feval(a{1}); % update the frequency response plot
Note that the z workspace variable is used to retrieve the current zero locations
but it is not sufficient to merely modify that variable. You actually have to modify the line data so that
the plot gets updated. Also without the last line, the frequency response plot would not reflect the new
locations of the zeros.