필터 지우기
필터 지우기

Improper assignment with rectangular empty matrix

조회 수: 3 (최근 30일)
pamela sulis
pamela sulis 2015년 10월 29일
댓글: Ingrid 2015년 10월 29일
Hi! I have a struct s, I want inizialize dateAll with a matrix of zeros different for every loop I try this two codes:
1) for i=1:106
dateAll=zeros(size(s(1,i).locs),6);
end
this code run but return only the last value of dateAll
2) for i=1:106
dateAll(i)=zeros(size(s(1,i).locs),6);
end
To solve the problem of code 1) I think to use an index in dateAll but matlab generates an
error: 'Improper assignment with rectangular empty matrix'
Can you help me to find the error?

답변 (1개)

Ingrid
Ingrid 2015년 10월 29일
first of all, do you want to store the values of dateAll for each iteration or do you only want to use it inside your dateloop?
if the first is what yo are trying to achieve you should write
dateAll{i} = zeros(size(s(1,i).locs),6);
  댓글 수: 2
pamela sulis
pamela sulis 2015년 10월 29일
yes, I want to store the values in dateAll for each iteration. I try your solution but matlab generates another error
Cell contents assignment to a non-cell array object.
Error in ProvaArrayStruct (line 9)
dateAll{k}=zeros(size(s(1,k).locs),6);
Ingrid
Ingrid 2015년 10월 29일
that is probably because you already have the dateAll variable in your workspace. Delete it first before trying again.

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

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by