Error :Assignment has more non-singleton rhs dimensions than non-singleton subscripts

I got this problem " Assignment has more non-singleton rhs dimensions than non-singleton subscripts " My code is:
v(m,i,j,k,l)=(-1*ones(m,i,j,k,l) + 2*rand(m,i,j,k,l))+rand*(gbest(m,i,j,k,l)-p(m,i,j,k,l));
Thank you so much!

 채택된 답변

Walter Roberson
Walter Roberson 2012년 9월 12일
ones(m,i,j,k,l) results in an m x i x j x k x l array. You compute something with that array size, and try to store the array result into the single scalar location v(m,i,j,k,l)

추가 답변 (1개)

residual_2(i,j)=0.25*(residual(2*i-2,2*j-2)+residual(2*i-2,2*j-1)+residual(2*i-1,2*j-2)+residual(2*i-1,2*j-1));
How can i get rid of this error

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

질문:

Nam
2012년 9월 12일

편집:

2016년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by