Getting many outputs using blockproc

Illustration
Youssra - 2022-03-04T11:06:53+00:00
Question: Getting many outputs using blockproc

I want to apply SVD for each 4*4 blocks using the "blockproc" and get 3 outputs: U, S and V so I can reconstract all blocks together again but Matlab gets me "too many ouput arguments". How can I solve this problem?   fun = @(block_struct) svd(block_struct.data); [U S V] = blockproc(a, [4 4], fun) This is the error that I have: Error using blockproc Too many output arguments.  

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

No, this is not possible with blockproc().
 
You can use something like
 
function r = blocksvd(block_struct)
   [U, S, V] = svd(block_struct.data);
   Spad = nan(size(U));
   Vpad = Spad;
   Spad(1:size(S,1),1:size(S,2)) = S;
   Vpad(1:size(U,1),1:size(U,2)) = U;
   r = [U; Spad; Vpad];
 end

this returns a 12 x 4 array that can be broken up again into U, S, V.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!