-
Notifications
You must be signed in to change notification settings - Fork 3
/
Chapter_01_LpLq_demo.m
55 lines (44 loc) · 1.13 KB
/
Chapter_01_LpLq_demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
% Figure 1.1
% =========================================
% Demonstrating the Lp-Lq relationship and tendency to sparsity
t=[0:1:360]/360*2*pi;
x=cos(t);
y=sin(t);
% Case 1
p=2; q=1;
xp=x./(abs(x).^p+abs(y).^p).^(1/p);
yp=y./(abs(x).^p+abs(y).^p).^(1/p);
xq=x./(abs(x).^q+abs(y).^q).^(1/q);
yq=y./(abs(x).^q+abs(y).^q).^(1/q);
figure(1); clf;
h=plot(xp,yp,'--k'); hold on;
set(h,'LineWidth',2);
h=plot(xq,yq,'k');
set(h,'LineWidth',2);
axis image;
axis([-1.5 1.5 -1.5 1.5]);
grid on;
factor=sqrt(2);
h=plot(factor*xq,factor*yq,'-.k');
set(h,'LineWidth',2);
set(gca,'FontSize',18);
% print -depsc2 Chapter_01_LpLq_demo1.eps
% Case 2
p=1; q=0.5;
xp=x./(abs(x).^p+abs(y).^p).^(1/p);
yp=y./(abs(x).^p+abs(y).^p).^(1/p);
xq=x./(abs(x).^q+abs(y).^q).^(1/q);
yq=y./(abs(x).^q+abs(y).^q).^(1/q);
figure(1); clf;
h=plot(xp,yp,'--k'); hold on;
set(h,'LineWidth',2);
h=plot(xq,yq,'k');
set(h,'LineWidth',2);
axis image;
axis([-1.5 1.5 -1.5 1.5]);
grid on;
factor=2;
h=plot(factor*xq,factor*yq,'-.k');
set(h,'LineWidth',2);
set(gca,'FontSize',18);
% print -depsc2 Chapter_01_LpLq_demo2.eps