I have predefined the variable:
no_of_zeros = cell(1,54);
however when I run my code it says:
'Index exceeds matrix dimensions.
Error in testrun (line 32) no_of_zeros = size(mydata{i,1},5) - nnz(mydata{i,1}(:,5)); %number of zeros'
My script following the pre defined varaible is:
for i=1:length(mydata)
no_of_zeros = size(mydata{i,1},1) - nnz(mydata{i,1}(:,5)); %number of zeros
no_of_frames = (no_of_zeros/4) % number of frames
time = ((no_of_frames/fps)/2) % time up
jumph(i,1)=((a*(t*t))/2) % jump height
end
Where am I going wrong?

 채택된 답변

hossein
hossein 2014년 4월 21일

0 개 추천

In the first line of your for loop, you're referring to the fifth character of the cell mydata{i,1}. Is it possible that the cell you're referring to doesn't have enough characters? Also, no_of_zeros is scalar (it's size is 1), so you don't need to pre-define it. Just make sure "nnz(mydata{i,1}(:,5))" doesn't produce an error.

댓글 수: 1

Franchesca
Franchesca 2014년 4월 21일
The 5th character? I thought I was referring to the 5th column to count the number of zeros in that column?

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

추가 답변 (0개)

카테고리

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

질문:

2014년 4월 21일

댓글:

2014년 4월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by