How to make a nxm Vandermonde matrix?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Johanne
el 19 de Sept. de 2019
Editada: John D'Errico
el 19 de Sept. de 2019
How to make a mxn Vandermonde matrix?
n = 30;
start = -2;
stop = 2;
x = linspace(start,stop,n);
eps = 1;
rng(1);
r = rand(1,n) * eps;
y = x.*(cos(r+0.5*x.^3)+sin(0.5*x.^3));
%plot(x,y,'o');
m = 3;
B = y';
b = B(1:m);
A = fliplr(vander(x(1:m)))
This makes it a 3x3 matrix, and I want a nx3 matrix.
0 comentarios
Respuesta aceptada
John D'Errico
el 19 de Sept. de 2019
Editada: John D'Errico
el 19 de Sept. de 2019
A = x(:).^(2:-1:0);
That works as long as you are using MATLAB R2016b or later. Earlier releases would need to use bsxfun, or even repmat.
Note that in A, i used the convention that vander uses, having the higest order term first. This is somewhat standard in MATLAB, for example, with polyfit.
You used fliplr on the result of vander, so you have the constant term first in your example. Either way is acceptable, as long as you know what you are doing.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!