how to fix Index exceeds matrix dimensions ?

for i=1:jumlah
filename=strcat('C:\Users\Documents\MATLAB\data\dataujiKW\',num2str(i),'.jpg');
image=imread(filename);
value=cast(extraction(image),'single'); %extraction is a function
counter=counter+1;
result{counter,1}=image;
for i=1:9
result{counter,i+1}=extraction(i);
end
hasilesktraksi=[result{i,2:10}]; // error
end
but, if i run in command window with command : hasilesktraksi=[hasiluji{1,2:10}], it not error and give the result. help please, thanks

댓글 수: 4

DO NOT use image as the name of your variable since it's the name of a very important built in function and you will destroy it.
ElizabethR
ElizabethR 2016년 5월 7일
oohh yes, i've replace it, but i still getting the error Index exceeds matrix dimensions in hasilesktraksi=[result{i,2:10}]; i have no idea how to fix it. i am very dizzy. help me please
I tried, below. Did you even see my answer below???
ElizabethR
ElizabethR 2016년 5월 7일
편집: ElizabethR 2016년 5월 7일
yes, i've seen your answare below. thank you ^^

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

 채택된 답변

Image Analyst
Image Analyst 2016년 5월 7일

0 개 추천

Looks like you're confused by cell arrays and concatenation. Instead of this:
hasilesktraksi=[result{i,2:10}]; // error
try this:
hasilesktraksi = extraction(1:9);
It's the same thing but avoiding using confusing cell arrays.

댓글 수: 1

ElizabethR
ElizabethR 2016년 5월 7일
yes, you're right. thanks for explanation and reference. God Bless ^^

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

추가 답변 (0개)

카테고리

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

태그

질문:

2016년 5월 7일

편집:

2016년 5월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by