increasing spdiags matrix at each iteration

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

답변 (1개)

James Tursa
James Tursa 2017년 5월 19일
편집: James Tursa 2017년 5월 19일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 5월 19일

편집:

2017년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by