How can I get values for f in a matrix of dimension(100,1)?

Respuestas (2)

José-Luis
José-Luis el 18 de Sept. de 2017
Editada: José-Luis el 18 de Sept. de 2017
f =@(x,y) (1-x).^2 +100*(y-x.^2).^2;
dummy = linspace(-1,1,10);
[xx,yy] = ndgrid(dummy,dummy);
result = f(xx,yy);
result = result(:);
Alternatively:
result = bsxfun(f,dummy,dummy.');
result = result(:);
Jan
Jan el 18 de Sept. de 2017
Since R2016b with auto-expanding:
x = linspace(-1,1,10);
y = linspace(-1,1,10).';
f = (1-x).^2 + 100*(y - x.^2).^2;
f = f(:)

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Sept. de 2017

Respondida:

Jan
el 18 de Sept. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by