MATLAB Concatenating Functions -


i have function @(x) f(x) returns 3-by-3 matrix. want define function @(x) f(x) returns 3*n-by-3*n, f(x) repeated n times along diagonal, arbitrary n.

this can done arrays (instead of functions) pretty simply:

n = 5;  = repmat({magic(3)},[1,n]);  b = blkdiag(a{:}) 

but functions, there subtlety since arguments need passed. naive attempts unsuccessful:

f=@(x) magic(3);  f=@(x) blkdiag(repmat({f(x)},[1,n])) f=@(x) blkdiag({repmat({f(x)},[1,n])}) f=@(x) blkdiag(repmat({feval(@(xx) f(xx),x)},[1,n]))  

in general, there elegant ways concatenate/combine/repeat function?


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

http - Safari render HTML as received -