this is my code:
zeromatrix = zero(size(vec), 1) mean(aaa) = zeromatrix
where vec is 2 million X 1 mean is a 2 by 1 cell aaa is just a counter, so in this case, it is a 1
when i try to run it, it gives me:
??? In an assignmnt A(I) = B, the number of elements in B and I must be the same
anyone have any idea how to get past this? thanks

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 27일

0 개 추천

size() returns 2 values.
mean() is a MATLAB function so not to use it as a variable name.
To assign a matrix to a cell array, you might want to use {}. A{1}=zeromatrix;
Use a small size vec to test out your code first and then make it 2 million by 1.

댓글 수: 4

Andy
Andy 2011년 9월 27일
ok, i changed mean() to name(), because mean isnt what i wanted to use, what i wanted is have a cell to store the zeromatrix. any way to do that?
so now i have
name = cell(1,counter)
zeromatrix = zero(size(vec), 1)
name(aaa) = zeromatrix
Andy
Andy 2011년 9월 27일
by the way, the error now says
??? Conversion to cell from double is not possible
Fangjun Jiang
Fangjun Jiang 2011년 9월 27일
name = cell(1,counter)
zeromatrix = zero(size(vec))
name{aaa} = zeromatrix
Andy
Andy 2011년 9월 27일
thanks it worked!

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

추가 답변 (0개)

카테고리

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

태그

질문:

2011년 9월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by