📄 genfig_2b.m
字号:
% GENFIG_2B Reproduces figure 2b.
%
% USAGE
%
% GENFIG_2B(color, display, filename)
%
% INPUTS
%
% color Color (true) or grayscale (false) (optional, default = true)
% display Displays (true) or does not display (false) the figure (optional, default = true)
% filename Saves the figure in eps format under the name 'filename' (optional, default = not saved)
%
% COPYRIGHT
%
% This file is part of the Matlab code provided for the following
% reproducible paper:
%
% Olivier Roy and Martin Vetterli,
% "Dimensionality Reduction for Distributed Estimation in the Infinite Dimensional Regime",
% vol. 54, no. 4, pp. 1655-1669, April 2008.
%
% This program is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2 of the License, or (at your
% option) any later version. This software is distributed in the hope that
% it will be useful, but without any warranty; without even the implied
% warranty of merchantability or fitness for a particular purpose.
% See the GNU General Public License for more details
% (enclosed in the file GPL).
%
% GNU General Public License,
% Copyright (C) 2008,
% Audiovisual Communications Laboratory (LCAV),
% Ecole Polytechnique F閐閞ale de Lausanne (EPFL),
% CH-1015 Lausanne.
%
% COMMENTS
%
% Author: Olivier Roy
% Latest modifications: April 2, 2008.
function genfig_2b(color, display, filename)
% We set the default values for the input arguments
save = true;
if nargin < 3
save = false;
end
if nargin < 2
display = true;
end
if nargin < 1
color = true;
end
% We set the simulation parameters
rho = 0.5;
sigma = sqrt(1);
% We define the covariance matrices of the involved vectors
R_S = [1 rho; rho 1];
R_SX0 = R_S;
R_SX1 = R_S;
R_SX = [R_SX0 R_SX1];
R_N = sigma^2*eye(2);
R_X0 = R_S + R_N;
R_X1 = R_S + R_N;
R_X0X1 = R_S;
R_X = [R_X0 R_X0X1; R_X0X1' R_X1];
% We compute the distortion for different values of theta and vartheta
theta_val = [0:0.01:pi/2];
vartheta_val = theta_val;
dist = [];
dist_row = [];
for (theta = theta_val)
for (vartheta = vartheta_val)
Q_1 = [cos(theta) sin(theta)];
Q_2 = [cos(vartheta) sin(vartheta)];
C = [Q_1 zeros(1,2);zeros(1,2) Q_2];
dist_row = [dist_row trace(R_S - R_SX*C'*inv(C*R_X*C')*C*R_SX')];
end
dist = [dist;dist_row];
dist_row = [];
end
% We plot the figure
figure;
hold on
box on
contourf(theta_val, vartheta_val, dist',20);
if (color)
colormap('jet');
plot([0,theta_val(end)],[pi/4,pi/4], 'r-','LineWidth',2);
plot([pi/4,pi/4],[0,vartheta_val(end)], 'r-','LineWidth',2);
diameter = 0.03;
rectangle('Position', [pi/4-diameter/2, pi/4-diameter/2, diameter, diameter], 'Curvature',[1,1], 'EdgeColor', [1 0 0], 'FaceColor', [1 0 0]);
else
map = gray(256);
map = map(100:256,:);
colormap(map);
plot([0,theta_val(end)],[pi/4,pi/4], 'k-','LineWidth',2);
plot([pi/4,pi/4],[0,vartheta_val(end)], 'k-','LineWidth',2);
diameter = 0.03;
rectangle('Position', [pi/4-diameter/2, pi/4-diameter/2, diameter, diameter], 'Curvature',[1,1], 'EdgeColor', [0 0 0], 'FaceColor', [0 0 0])
end
axis([0, theta_val(end), 0, vartheta_val(end)]);
grid off
colorbar
if save
xlabel('xLabel');
ylabel('yLabel');
title('title');
set(text(pi/4+0.03,pi/4+0.05, 'pLabel'));
saveas(gcf, filename,'psc2');
end
if display
xlabel('\theta [rad]');
ylabel('\vartheta [rad]');
if (color)
set(text(pi/4+0.03,pi/4+0.05, '(\theta_0,\vartheta_0)'),'Color',[1 0 0]);
else
set(text(pi/4+0.03,pi/4+0.05, '(\theta_0,\vartheta_0)'),'Color',[0 0 0]);
end
else
close gcf
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -