필터 지우기
필터 지우기

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

조회 수: 6 (최근 30일)
Dear community, help with this.
Voc=Clean(:,7);
a=Voc(1:3);
j=1;k=9;
t=length(Voc);
for i=1:t;
v= Voc(j:k,1);
a=cellfun(@mean,v);
Voc_p(i,1)=a;
j=j+9;
k=k+9;
end
A datatable was convert into a array previously and appears this error:
Unable to perform assignment because the indices on the left side are not compatible with the size of the
right side.
Error in Prueba_1 (line 29)
Voc_p(i,1)=a;
How can I fix this?
Thank u

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 10일
v= Voc(j:k,1);
That is creating a non-scalar cell array
a=cellfun(@mean,v);
That is going through each cell member and taking the mean of each. The fact that you did not get an error on this line tells us that each cell member was a scalar or a vector, not empty and not 2 D or more. The end result will be a vector of length k-j+1 = 9.
Voc_p(i,1)=a;
You are trying to store that vector of length 9 into a single location, Voc_p(i,1)
  댓글 수: 13
Walter Roberson
Walter Roberson 2019년 6월 11일
You moved the *9 to inside the floor() when it needs to be outside.
lastidx = floor(nrow/9) * 9;
Jonathan Bijman
Jonathan Bijman 2019년 6월 11일
It works!
Thank U so much Walter for all the troubles I caused u.
I hope can I count for your help in the future, for this amateur like me.
Thank u so much =)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by