Files
FAR_CS/0 - example/lyh - 非满秩相变/untitled.m
T
2024-11-11 16:33:48 +08:00

148 lines
2.3 KiB
Matlab

len = 256;
w = 0.05;
m = [0:len-1];
n = m;
B = m - n';
B = (sin(2*pi*w*B)./(pi*B));
for i = 1:len
B(i,i) = 2*w;
end
t = [0:0.1:25.5];
r = 1/sqrt(2*pi*1)*exp(-t.^2/2*1);
gau = toeplitz(r);
%%
len = 64;
w = 0.2;
m = [0:len-1];
n = m;
B = m - n';
B_new = sin(2*pi*w*B)./(pi*B);
for i = 1:len
B_new(i,i) = 2*w;
end
cor = 0.236;
final = zeros(len^2,len^2);
for j = 1:len
for k = 1:len
tmp = sin(2*pi*w*(cor*B+(j-k)))./(pi*(cor*B+(j-k)));
tmp(cor*B+(j-k) == 0) = 2*w;
final((j-1)*len+1:j*len,(k-1)*len+1:k*len) = tmp.*B_new;
end
end
[a,b] = eig(final);
plot(diag(b));
c = diag(b);
M = c'*c;
plot(sort(M(:)));
%%
K = kron(B,B);
[a,b] = eig(B);
plot(diag(b));
c = diag(b);
M = c*c';
plot(sort(M(:)));
f = zeros(1,1200);
f(1:120) = randn(120,1);
f(1081:1200) = randn(120,1);
t = ifft(f);
t = t(1:64);
%B = B + diag(exp(1i*2*pi*0.3*[0:len-1]))*B*diag(exp(1i*2*pi*0.3*[0:len-1]))';
[a,b] = eig(B);
% plot(sort(abs(diag(b))))
D = B(1:8,:);
E = B(1:2:16,:);
[U2,S2,V2] = svd(D);
[U3,S3,V3] = svd(E);
%sel = (1:2:1023);
o = randn(1024,1024);
%o = orth(o);
sel = randperm(1024,512);
% C = o(sel,:)*b;
% D = B(sel,:);
% E = o(sel,randperm(1024,204));
D = B(1:512,:);
C = B(sel,:);
E = B(1:2:1023,:);
[U,S,V] = svd(C);
[U2,S2,V2] = svd(D);
[U3,S3,V3] = svd(E);
s = diag(S);
s2 = diag(S2);
s3 = diag(S3);
figure;
subplot(1,4,1);
plot(s);
subplot(1,4,2);
plot(s2);
subplot(1,4,3);
plot(s3);
q = sum(s);
subplot(1,4,4);
plot(flipud(abs(diag(b))));
%t1 = squeeze(resulta(:,:,1));
%t2 = squeeze(resultb(:,:,1));
% t1 = squeeze(resulta(:,:,2));
% t2 = squeeze(resultb(:,:,2));
% figure;
result_cona = reshape(result_cona,200,20,2);
result_conb = reshape(result_conb,200,20,2);
for i = 1:2
t1 = squeeze(result_cona(:,:,i)+t3(:,:,i))/2;
t2 = squeeze(result_conb(:,:,i)+t4(:,:,i))/2;
figure
hold on
plot(mean(t1),'-r.');
plot(mean(t2),'-bo');
h = legend("$P_{\ell_{2,1}}'$","$P_{\ell_{2,1}}$","Location","Southeast","Fontsize",15);
set(h,'Interpreter','latex');
xlabel("\fontname{Times New Roman} Block Sparsity \it s_B");
ylabel("\fontname{Times New Roman} Block Contribution Error");
end
xlabel("\fontname{Times New Roman} Block Sparsity \it K");
ylabel("\fontname{Times New Roman} Block Contribution Error");
t3 = result_cona;
t4 = result_conb;