当前位置:网站首页>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 ~
边栏推荐
- execute immediate 简单示例合集(DML)
- Web系统常见安全漏洞介绍及解决方案-sql注入
- MySQL transaction (this is enough...)
- Summary: the difference between pod and container
- Basic knowledge of PHP language (super detailed)
- 17.机器学习系统的设计
- CV semantic segmentation model sketch (2)
- 动态规划问题(七)
- The 30th day of question brushing
- Dynamic programming (V)
猜你喜欢

动态规划问题(五)
![[micro services ~nacos] Nacos service providers and service consumers](/img/b7/47ecd6979ccfeb270261681d6130be.png)
[micro services ~nacos] Nacos service providers and service consumers

聊聊异步编程的 7 种实现方式
![[ESN] learning echo state network](/img/8e/09cc2d2c0e0ee24e9bee13979b03cb.png)
[ESN] learning echo state network

Geth installation

Software designer - intermediate, exam summary

requestVideoFrameCallback() 简单实例

【开发教程10】疯壳·开源蓝牙心率防水运动手环-蓝牙 BLE 收发

110道 MySQL面试题及答案 (持续更新)

Advanced area of attack and defense world web masters ics-06
随机推荐
动态规划问题(五)
Samsung asset management (Hong Kong) launched yuancosmos ETF to focus on investing in the future tuyere track
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
html+css+php+mysql实现注册+登录+修改密码(附完整代码)
[development tutorial 10] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - Bluetooth ble transceiver
[ESN] learning echo state network
MySQL的存储过程
最长上升子序列
Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
NPM run serve stuck at 40%
PTA (daily question) 7-69 narcissus number
动态规划问题(二)
MySQL stored procedure
1331. 数组序号转换 : 简单模拟题
R语言怎么学
Advanced area of attack and defense world web masters warmup
15.模型评估和选择问题
Cause analysis of 12 MySQL slow queries
Dynamic programming problem (VII)
Web系统常见安全漏洞介绍及解决方案-sql注入