-2
코드를 실행하고 "인덱스가 매트릭스 크기를 초과합니다"라는 오류가 표시되지만 이유를 모르겠습니다."인덱스가 매트릭스 크기를 초과합니다."오류
function [ p ] = myIsort2(p)
%myIsort2 is based on myIsort but instead of sorting a row vector into
%increasing order it sorts a structure array into decreasing order
global order
n=length(p);
for i=2:n
x=p(1,i).exponent;
y=p(1,i).coeff;
j=i-1;
while (j~=0) && order(x,p(1,j).exponent)==1
%compares the order between 2 row vectors of the exponential field
%in order to sort them by making the smallest one come after the
%largest one
p(1,j+1).exponent=p(1,j).exponent;
p(1,j+1).coeff=p(1,j).coeff;
j=j-1;
end
p(1,j+1).exponent=x;
p(1,j+1).coeff=y;
end
end
감사 : 여기
는 코드입니다.
입력 매개 변수와 오류가 발생한 행이 없어도 오류를 이해하는 것은 어렵습니다. 적어도 명백한 오류는 보이지 않습니다. 나는'dbstop if error'를 사용하고 인덱스가 멈출 때 그것을 검사 할 것입니다. – Daniel