当前位置:网站首页>Common measurement matrix and matlab code of compressed sensing
Common measurement matrix and matlab code of compressed sensing
2022-07-29 00:35:00 【Love learning one by one】
List of articles
Preface
The design of observation matrix is the second step of compressed sensing , Here is the commonly used measurement matrix matlab Code , For everyone to find and use . The code content is referenced from the following website , And modify some of the codes , If you want to explore its principle, you can enter this website to find ~
https://blog.csdn.net/jbb0523/article/details/44700735
One 、 What is the measurement matrix ?
The measurement matrix is used to enable people to see the observed values obtained by the instrument y y y. The concrete expression is : y = Φ x y=\varPhi x y=Φx among , x x x It's the original signal , y y y For observed signals . How many signals can be observed from the original signal , It is determined by the measurement matrix , Therefore, it will involve the concept of sampling rate . The usual concept of sampling rate is defined as the number of rows of the measurement matrix / Number of columns , namely M / N M/N M/N, If you are interested, you can consult the materials for learning ~
Two 、 Commonly used measurement matrix and its matlab Code
1、 Random Gaussian measurement matrix
function [ Phi ] = GaussMtx( M,N )
%GaussMtx Summary of this function goes here
% Generate Bernoulli matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The Gauss matrix
%% Generate Gauss matrix
Phi = randn(M,N);
%Phi = Phi/sqrt(M);
end
2、 Random Bernoulli measurement matrix
function [ Phi ] = BernoulliMtx( M,N )
%BernoulliMtx Summary of this function goes here
% Generate Bernoulli matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The Bernoulli matrix
Phi = randi([0,1],M,N);%If your MATLAB version is too low,please use randint instead
Phi(Phi==0) = -1;
Phi = Phi/sqrt(M); % According to the formula, there should be this sentence
end
3、 Partial Hadamard measurement matrix
function [ Phi ] = PartHadamardMtx( M,N )
%PartHadamardMtx Summary of this function goes here
% Generate part Hadamard matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The part Hadamard matrix
%% parameter initialization
%Because the MATLAB function hadamard handles only the cases where n, n/12,
%or n/20 is a power of 2
L_t = max(M,N);%Maybe L_t does not meet requirement of function hadamard
L_t1 = (12 - mod(L_t,12)) + L_t;
L_t2 = (20 - mod(L_t,20)) + L_t;
L_t3 = 2^ceil(log2(L_t));
L = min([L_t1,L_t2,L_t3]);%Get the minimum L
%% Generate part Hadamard matrix
Phi = [];
Phi_t = hadamard(L);
RowIndex = randperm(L);
Phi_t_r = Phi_t(RowIndex(1:M),:);
ColIndex = randperm(L);
Phi = Phi_t_r(:,ColIndex(1:N));
end
4、 Partial Fourier measurement matrix
function [ Phi ] = PartFourierMtx( M,N )
%PartFourierMtx Summary of this function goes here
% Generate part Fourier matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The part Fourier matrix
%% Generate part Fourier matrix
Phi_t = fft(eye(N,N))/sqrt(N);%Fourier matrix
RowIndex = randperm(N);
Phi = Phi_t(RowIndex(1:M),:);%Select M rows randomly
%normalization
for ii = 1:N
Phi(:,ii) = Phi(:,ii)/norm(Phi(:,ii));
end
end
5、 Sparse random measurement matrix
function [ Phi ] = SparseRandomMtx( M,N,d )
%SparseRandomMtx Summary of this function goes here
% Generate SparseRandom matrix
% M -- RowNumber
% N -- ColumnNumber
% d -- The number of '1' in every column,d<M
% Phi -- The SparseRandom matrix
%% Generate SparseRandom matrix
Phi = zeros(M,N);
for ii = 1:N
ColIdx = randperm(M);
Phi(ColIdx(1:d),ii) = 1;
end
end
6、 Toplitz measurement matrix
function [ Phi ] = ToeplitzMtx( M,N )
%ToeplitzMtx Summary of this function goes here
% Generate Toeplitz matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The Toeplitz matrix
%% Generate a random vector
% %(1)Gauss
% u = randn(1,2*N-1);
%(2)Bernoulli
u = randi([0,1],1,2*N-1);
u(u==0) = -1;
%% Generate Toeplitz matrix
Phi_t = toeplitz(u(N:end),fliplr(u(1:N)));
Phi = Phi_t(1:M,:);
end
7、 Cyclic measurement matrix
function [ Phi ] = CirculantMtx( M,N )
%CirculantMtx Summary of this function goes here
% Generate Circulant matrix
% M -- RowNumber
% N -- ColumnNumber
% Phi -- The Circulant matrix
%% Generate a random vector
% %(1)Gauss
% u = randn(1,N);
%(2)Bernoulli
u = randi([0,1],1,N);
u(u==0) = -1;
%% Generate Circulant matrix
Phi_t = toeplitz(circshift(u,[1,1]),fliplr(u(1:N)));
Phi = Phi_t(1:M,:);
end
summary
The above is the code content to be shown in this section . I have consulted a lot of data in the process of learning compressed sensing , Also tested a lot of code , The code here does not lose money . If the code still deviates from its principle , You can also modify it according to the principle ~
边栏推荐
- Oracle super full SQL, details crazy
- 【开发教程10】疯壳·开源蓝牙心率防水运动手环-蓝牙 BLE 收发
- Shell编程规范与变量
- Introduction and solution of common security vulnerabilities in web system CSRF attack
- PTA (daily question) 7-69 narcissus number
- CDN mode uses vant components, and components cannot be called after they are introduced
- Dynamic programming problem (6)
- [applet project development -- JD mall] uni app commodity classification page (first)
- Idea connection database
- [small bug diary] Navicat failed to connect to MySQL | MySQL service disappeared | mysqld installation failed (this application cannot run on your computer)
猜你喜欢

Google browser, no installation required

Dynamic programming problem (6)

vulnhub:BTRSys2

vulnhub:Sar

What does the expression > > 0 in JS mean

vscode下链接远程服务器安装插件失败、速度慢等解决方法

Event extraction and documentation (2008-2017)

【开发教程11】疯壳·开源蓝牙心率防水运动手环-整机功能代码讲解

110 MySQL interview questions and answers (continuously updated)

时间序列统计分析
随机推荐
Laravel permission control
Advanced area of attack and defense world web masters training www robots
Software designer - intermediate, exam summary
execute immediate 简单示例合集(DML)
Calculate properties and listeners
手把手教你安装Latex(保姆级教程)
CV target detection model sketch (2)
动态规划问题(二)
PTA (daily question) 7-77 encryption
Idea2021.2 installation and configuration (continuous update)
Advanced area of attack and defense world web masters supersqli
Dynamic programming problem (4)
How to learn R language
PTA (daily question) 7-73 turning triangle
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
requestVideoFrameCallback() 简单实例
MySQL 分库分表及其平滑扩容方案
Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
动态规划问题(三)
IDEA2021.2安装与配置(持续更新)