Mercurial > matrix-functions
comparison matrixcomp/cpltaxes.m @ 0:8f23314345f4 draft
Create local repository for matrix toolboxes. Step #0 done.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Wed, 06 May 2015 14:56:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f23314345f4 |
---|---|
1 function x = cpltaxes(z) | |
2 %CPLTAXES Determine suitable AXIS for plot of complex vector. | |
3 % X = CPLTAXES(Z), where Z is a complex vector, | |
4 % determines a 4-vector X such that AXIS(X) sets axes for a plot | |
5 % of Z that has axes of equal length and leaves a reasonable amount | |
6 % of space around the edge of the plot. | |
7 | |
8 % Called by FV, GERSH, PS and PSCONT. | |
9 | |
10 % Set x and y axis ranges so both have the same length. | |
11 | |
12 xmin = min(real(z)); xmax = max(real(z)); | |
13 ymin = min(imag(z)); ymax = max(imag(z)); | |
14 | |
15 % Fix for rare case of `trivial data'. | |
16 if xmin == xmax, xmin = xmin - 1/2; xmax = xmax + 1/2; end | |
17 if ymin == ymax, ymin = ymin - 1/2; ymax = ymax + 1/2; end | |
18 | |
19 if xmax-xmin >= ymax-ymin | |
20 ymid = (ymin + ymax)/2; | |
21 ymin = ymid - (xmax-xmin)/2; ymax = ymid + (xmax-xmin)/2; | |
22 else | |
23 xmid = (xmin + xmax)/2; | |
24 xmin = xmid - (ymax-ymin)/2; xmax = xmid + (ymax-ymin)/2; | |
25 end | |
26 axis('square') | |
27 | |
28 % Scale ranges by 1+2*alpha to give extra space around edges of plot. | |
29 | |
30 alpha = 0.1; | |
31 x(1) = xmin - alpha*(xmax-xmin); | |
32 x(2) = xmax + alpha*(xmax-xmin); | |
33 x(3) = ymin - alpha*(ymax-ymin); | |
34 x(4) = ymax + alpha*(ymax-ymin); | |
35 | |
36 if x(1) == x(2), x(2) = x(2) + 0.1; end | |
37 if x(3) == x(4), x(4) = x(3) + 0.1; end |