increasing spdiags matrix at each iteration

1 visualización (últimos 30 días)
sensation
sensation el 19 de Mayo de 2017
Editada: James Tursa el 19 de Mayo de 2017
Hi, I was wondering if someone has an idea how to horzcat at each iteration spdiag matrix? Thanks!!!
ot = ones(N,1);
N=50;
for i=1:10
if i=1
A2 = spdiags([ot ot -ot -ot],[0 N -1 N-1],N,N*2);
else
%%desired result
%%for i=2 it should be A2 = horzcat(A2,A2);
% for i=3 A2 = horzcat(A2,A2,A2) and so on;
end
end

Respuestas (1)

James Tursa
James Tursa el 19 de Mayo de 2017
Editada: James Tursa el 19 de Mayo de 2017
A2 = repmat(A2,1,i);
But it seems to me that you may be running into memory problems with this, since A2 is recursively using the last A2 with repmat to build the new A2.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by