Skip to content

Commit 5f9cdb3

Browse files
author
Shahar Kovalsky
committedOct 19, 2014
Controlling Singular Values
1 parent 65969a7 commit 5f9cdb3

35 files changed

+3434
-0
lines changed
 

‎.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
##---------------------------------------------------
2+
## Remove autosaves generated by the Matlab editor
3+
## We have git for backups!
4+
##---------------------------------------------------
5+
6+
# Windows default autosave extension
7+
*.asv
8+
9+
# OSX / *nix default autosave extension
10+
*.m~
11+
12+
# Compiled MEX binaries (all platforms)
13+
*.mex*

‎ContSingVal_LowRes.pdf

1.7 MB
Binary file not shown.

‎addaxis/Readme.txt

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
% Removed debugging line 11/15/2005
2+
3+
% Added zoom support for version R14SP2 11/24/2005
4+
5+
% Updated installation notes 11/24/2005
6+
7+
% In addaxisplot, only automatically change color to the axis color, if no
8+
% other color specified 11/28/2005
9+
10+
% changed implementation to use appdata instead of userdata. (setaddaxisdata.m, getaddaxisdata.m)
11+
% Also, added addaxisreset to delete added axes and reset the parent axis
12+
% and addaxisset which is used to set the ylimits of any axis after plotting 12/23/05
13+
14+
% changed splot.m to aa_splot.m to avoid the same name as splot.m that already
15+
% exists in another toolbox. 2/15/06
16+
17+
% changed addaxislabel so it doesn't matter if you use it addaxislabel(axis_number,label)
18+
% or addaxislabel(label,axis_number) 2/15/06
19+
20+
21+
Files
22+
23+
addaxis.m
24+
addaxisplot.m
25+
addaxislabel.m
26+
addaxisset.m
27+
addaxisreset.m
28+
getaddaxisdata.m
29+
setaddaxisdata.m
30+
aa_splot.m
31+
32+
zoom_R11.1_.m
33+
34+
zoom_R14SP2_.m
35+
buttonupfcn2D_R14SP2_.m
36+
37+
38+
Installation Notes:
39+
-------------------------------------------
40+
41+
Put the addaxis files and aa_splot anywhere in your matlab path.
42+
43+
addaxis will work fine, and zoom properly except the axis limits of the added
44+
axes will not update unless the following modifications to the zoom function(s)
45+
are made. These have been tested in R11.1 and R14SP2. The R14 files should
46+
work in later versions. If not, please let me know.
47+
48+
49+
Zoom modifications
50+
------------------------------------------
51+
52+
For version R11.1, inside <matlab_directory>/toolbox/matlab/graph2d/
53+
rename zoom.m to zoom_orig.m, copy zoom_R11.1_.m into the directory
54+
and rename it zoom.m.
55+
56+
For version R14SP2, inside <matlab_diretory>/toolbox/matlab/graph2d/
57+
rename zoom.m to zoom_orig.m, copy zoom_R14SP2_.m into the directory
58+
and rename it zoom.m. ALSO, inside
59+
<matlab_directory>/toolbox/matlab/graphics/@graphics/@zoom/
60+
rename buttonupfcn2D.m to buttonupfcn2D_orig.m, copy
61+
buttonupfcn2D_R14SP2.m into the directory and rename it
62+
buttonupfcn2D.m
63+
64+
65+
The modifications to the zoom capability in matlab simply get the
66+
ylimits before and after any zoom operation is completed and then
67+
scales the added axes limits accordingly.
68+
69+
70+
71+
72+

‎addaxis/aa_splot.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function varargout = aa_splot(varargin)
2+
%AA_SPLOT replaces plot command and automatically changes color
3+
%
4+
% This function is a replacement for the plot command.
5+
% It automatically changes the color with subsequent
6+
% uses of aa_splot.
7+
%
8+
% Usage is exactly the same as for plot.
9+
10+
np = get(gca,'nextplot');
11+
oldplots = get(gca,'children');
12+
13+
cord = get(gca,'colorord');
14+
15+
if ~isempty(oldplots)
16+
lastcolor = get(oldplots(1),'color');
17+
if lastcolor == cord(1,:),
18+
set(gca,'colorord',cord(mod([0:6]+1,7)+1,:));
19+
end
20+
end
21+
22+
hold on;
23+
24+
h = plot(varargin{:});
25+
26+
for IND = 1:nargout
27+
varargout(IND) = {h};
28+
end
29+
30+
%if nargout > 0, varargout{:} = h; end;
31+
32+
set(gca,'colorord',cord(mod([0:6]+1,7)+1,:));
33+
set(gca,'nextplot',np);
34+
set(gca,'box','on');

‎addaxis/addaxis.m

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
function addaxis(varargin)
2+
%ADDAXIS adds an axis to the current plot
3+
% you can add as many axes as you want.
4+
%
5+
% usage:
6+
% use it just like plot, except, you need to specify the abscissa
7+
% and the third input argument should be the axis limits, if at all.
8+
%
9+
% example:
10+
%
11+
% x = 0:.1:4*pi;
12+
% plot(x,sin(x));
13+
% addaxis(x,sin(x-pi/3));
14+
% addaxis(x,sin(x-pi/2),[-2 5],'linewidth',2);
15+
% addaxis(x,sin(x-pi/1.5),[-2 2],'v-','linewidth',2);
16+
% addaxis(x,5.3*sin(x-pi/1.3),':','linewidth',2);
17+
%
18+
% addaxislabel(1,'one');
19+
% addaxislabel(2,'two');
20+
% addaxislabel(3,'three');
21+
% addaxislabel(4,'four');
22+
% addaxislabel(5,'five');
23+
%
24+
% addaxisplot(x,sin(x-pi/2.3)+2,3,'--','linewidth',2);
25+
% addaxisplot(x,sin(x-pi/1),5,'--','linewidth',2);
26+
%
27+
% legend('one','two','three','four','five','three-2','five-2');
28+
%
29+
%
30+
%
31+
% Also requires AA_SPLOT.m, a modified plot function that automatically
32+
% changes colors everytime you plot.
33+
%
34+
% See also
35+
% ADDAXISPLOT, ADDAXISLABEL, AA_SPLOT
36+
37+
% NOTE: the 'userdata' of the main axis holds a cell array for each axis
38+
% each cell holds a vector. The first element is the axis handle
39+
% the rest are handles to lines that correspond to that axis lines.
40+
41+
42+
% get current axis
43+
cah = gca;
44+
45+
46+
if nargin>=3 & ~isstr(varargin{3})
47+
yl2 = varargin{3};
48+
indkeep = setdiff(1:nargin,3);
49+
[varargintemp{1:nargin-1}] = deal(varargin{indkeep});
50+
varargin = varargintemp;
51+
end
52+
53+
% assume existing plot has axes scaled the way you want.
54+
yl = get(cah,'ylim');
55+
cpos = get(cah,'position');
56+
set(cah,'box','off');
57+
58+
% get userdata of current axis. this will hold handles to
59+
% additional axes and the handles to their corresponding plots
60+
% in the main axis
61+
% axh = get(cah,'userdata');
62+
axh = getaddaxisdata(cah,'axisdata');
63+
64+
ledge = cpos(1);
65+
if length(axh)>=1
66+
if length(axh)/2 == round(length(axh)/2)
67+
rpos = get(axh{end-1}(1),'position');
68+
redge = rpos(1);
69+
lpos = get(axh{end}(1),'position');
70+
ledge = lpos(1);
71+
else
72+
rpos = get(axh{end}(1),'position');
73+
redge = rpos(1);
74+
if length(axh)>1
75+
lpos = get(axh{end-1}(1),'position');
76+
ledge = lpos(1);
77+
end
78+
end
79+
else
80+
redge = cpos(3)+cpos(1);
81+
ledge = cpos(1);
82+
end
83+
84+
totwid = redge-ledge;
85+
86+
% assume axes are added on right, then left, then right, etc.
87+
numax = length(axh)+1;
88+
89+
90+
% parameters setting axis separation
91+
axcompleft=0.12;
92+
if numax == 1
93+
axcompright = 0.0;
94+
else
95+
axcompright = 0.12;
96+
end
97+
98+
if numax/2 == round(numax/2)
99+
side = 'left';
100+
xpos = ledge-axcompleft*totwid;
101+
else
102+
side = 'right';
103+
xpos = redge+axcompright*totwid;
104+
end
105+
106+
h_ax = axes('position',[xpos, cpos(2), cpos(3)*.015, cpos(4)]);
107+
% plot in new axis to get the automatically generated ylimits
108+
hplt = plot(varargin{:});
109+
110+
if ~exist('yl2')
111+
yl2 = get(h_ax,'ylim');
112+
end
113+
114+
115+
set(h_ax,'yaxislocation',side);
116+
set(h_ax,'color',get(gcf,'color'));
117+
set(h_ax,'box','off');
118+
set(h_ax,'xtick',[]);
119+
set(hplt,'visible','off');
120+
121+
set(h_ax,'ylim',yl2);
122+
123+
124+
% rescale all y-values
125+
y = varargin{2};
126+
127+
y = (y-yl2(1))./(yl2(2)-yl2(1)).*(yl(2)-yl(1))+yl(1);
128+
129+
varargin{2} = y;
130+
axes(cah)
131+
hplts = aa_splot(varargin{:});
132+
set(gca,'ylim',yl);
133+
134+
% store the handles in the axis userdata
135+
axh{length(axh)+1} = [h_ax;hplts];
136+
% set(cah,'userdata',axh);
137+
setaddaxisdata(cah,axh,'axisdata');
138+
set(cah,'box','off');
139+
140+
% set the axis color if a single line was added to the plot
141+
if length(hplts)==1
142+
set(h_ax,'ycolor',get(hplts,'color'));
143+
end
144+
145+
% Now, compress main axis so the extra axes don't interfere
146+
% or dissappear
147+
148+
% get axis handles
149+
axhand = cah;
150+
postot(1,:) = get(cah,'position');
151+
for I = 1:length(axh)
152+
axhand(I+1) = axh{I}(1);
153+
postot(I+1,:) = get(axhand(I+1),'position');
154+
end
155+
156+
if numax/2 == round(numax/2)
157+
% side = 'left';
158+
159+
set(cah,'position',[postot(1,1)+axcompleft*totwid,postot(1,2), ...
160+
postot(1,3)-axcompleft*totwid, postot(1,4)]);
161+
indshift = [2:2:size(postot,1)-1];
162+
for I = 1:length(indshift)
163+
set(axhand(indshift(I)+1),'position',[postot(indshift(I)+1,1)+axcompleft*totwid, ...
164+
postot(indshift(I)+1,2:end)]);
165+
end
166+
167+
else
168+
% side = 'right';
169+
170+
set(cah,'position',[postot(1,1),postot(1,2),postot(1,3)-axcompright*totwid,postot(1,4)]);
171+
indshift = [1:2:size(postot,1)-1];
172+
for I = 1:length(indshift)
173+
set(axhand(indshift(I)+1),'position',[postot(indshift(I)+1,1)-axcompright*totwid, ...
174+
postot(indshift(I)+1,2:end)]);
175+
end
176+
177+
end

‎addaxis/addaxislabel.m

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function varargout = addaxislabel(varargin)
2+
%ADDAXISLABEL adds axis labels to axes made with ADDAXIS.m
3+
%
4+
% handle_to_text = addaxislabel(axis_number, label);
5+
%
6+
% See also
7+
% ADDAXISPLOT, ADDAXIS, SPLOT
8+
9+
if isstr(varargin{1}),
10+
axnum = varargin{2};
11+
label = varargin{1};
12+
else
13+
label = varargin{2};
14+
axnum = varargin{1};
15+
end
16+
17+
% get current axis
18+
cah = gca;
19+
% axh = get(cah,'userdata');
20+
axh = getaddaxisdata(cah,'axisdata');
21+
22+
% get axis handles
23+
axhand = cah;
24+
postot(1,:) = get(cah,'position');
25+
for I = 1:length(axh)
26+
axhand(I+1) = axh{I}(1);
27+
postot(I+1,:) = get(axhand(I+1),'position');
28+
end
29+
30+
% set current axis to the axis to be labeled
31+
axes(axhand(axnum));
32+
htxt = ylabel(label);
33+
set(htxt,'color',get(axhand(axnum),'ycolor'));
34+
35+
% set current axis back to the main axis
36+
axes(cah);
37+
38+
if nargout == 1
39+
varargout{1} = htxt;
40+
end

0 commit comments

Comments
 (0)
Please sign in to comment.