A brief talk on compression perception (vii): MATLAB implementation of common measurement matrices

Source: Internet
Author: User

1. Random Gaussian measurement matrix

function [Phi] = gaussmtx (m,n) This function goeshere%      M-- Rownumbe R%   N-- columnnumber%   Phi--The Gauss matrixpercent Generate Gauss matrix        = Randn (m,n);     %phi = phi/sqrt (M); end

2. Random beta-effort measurement matrix

function [Phi] =bernoullimtx (m,n)%BERNOULLIMTX Summary of Thisfunction goes here%Generate Bernoulli Matrix% M--RowNumber% N--ColumnNumber% Phi--The Bernoulli matrix%% (1) Generate Bernoulli matrix (the first kind)%1--p=0.5-1--p=0.5Phi= Randi ([0,1],M,N);%I F Your MATLAB version istoo low,please use Randint instead Phi (Phi==0) = -1; %phi = phi/sqrt (M);% %% (2) Generate Bernoulli matrix (the second kind)% %1--p=1/6-1--p=1/6  0--2/3% Phi = Randi ([-1,4],M,N);%I F Your MATLAB version istoo low,please use Randint instead% Phi (phi==2) =0;%p=1/6% Phi (phi==3) =0;%p=1/6% Phi (phi==4) =0;%p=1/6%%phi = PHI*SQRT (3/M); end

3. Partial Hada Measurement matrix

function [Phi] =parthadamardmtx (m,n)%PARTHADAMARDMTX Summary of Thisfunction 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 caseswhereN, n/ A,%or n/ -  isA power of2l_t= max (m,n);%maybe l_t does not meet requirement of function Hadamard l_t1= ( A-MoD (l_t, A)) +l_t; L_t2= ( --MoD (l_t, -)) +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 Thisfunction 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 forII =1: N Phi (:, II)= Phi (:, II)/Norm (Phi (:, ii)); EndEnd

5. Sparse Random Measurement matrix

function [Phi] =sparserandommtx (m,n,d)%SPARSERANDOMMTX Summary of Thisfunction goes here%Generate sparserandom Matrix% M--RowNumber% N--ColumnNumber% d--the number of'1' inchEvery column,d<M% Phi--The sparserandom matrix%%Generate sparserandom Matrix Phi=zeros (m,n);  forII =1: N colidx=randperm (M); Phi (Colidx (1:D), ii) =1; EndEnd

6. Gnas measurement matrix and cyclic measurement matrix

function [Phi] =toeplitzmtx (m,n)%TOEPLITZMTX Summary of Thisfunction 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
function [Phi] =circulantmtx (m,n)%CIRCULANTMTX Summary of Thisfunction 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

Reference Source: http://blog.csdn.net/jbb0523/article/details/44700735

A brief talk on compression perception (vii): MATLAB implementation of common measurement matrices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.