How can I create a matrix with a function instead of multiplication
Mostra commenti meno recenti
Hi there,
Lets say I have a Function: F(x,y)
Data: x = { x1,x2 … ,xn } y = { y1,y2 … ,yn }
How can I efficiently create the matrix M =
[ F(x1,y1) , F(x1,y2) , … , F(x1,yn);
F(x2,y1) , F(x2,y2) , … , F(x2,yn);
…
…
F(xn,y1) , F(xn,y2) , … , F(xn,yn)];
Risposte (1)
the cyclist
il 16 Ott 2014
Modificato: the cyclist
il 16 Ott 2014
x = [1,2,3];
y = [4,5,6];
F = @(X,Y) X .* Y.^2;
M = bsxfun(F,x,y')
1 Commento
Mohammad Abouali
il 17 Ott 2014
Modificato: Mohammad Abouali
il 17 Ott 2014
It needs a transpose at the end or
M = bsxfun(F,x',y)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!