필터 지우기
필터 지우기

Matlab error that I can't figure out please help!

조회 수: 1 (최근 30일)
Brandon
Brandon 2013년 4월 17일
I'm working with the code that I will show below and I keep on getting the error:
"Subscript indices must either be real positive integers or logicals.
Error in opticalflow2D (line 62)
f5 = X1(( ndxm.*cos(1)+ndxn.*sin(1) ));"
if true
X1 = [
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
];
if true
X2 = [
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
];
%imtool(X1)
%imtool(X2)
delta=1;
[fm,fn] = size(X1);
ndxm = 1+delta:fm-delta;
ndxn = 1+delta:fn-delta;
X1(ndxm)
f0 = X1(ndxm,ndxn);
fz = X2(ndxm,ndxn);
f1 = X1(ndxm,ndxn+delta);
f2 = X1(ndxm,ndxn-delta);
f3 = X1(ndxm+delta,ndxn);
f4 = X1(ndxm-delta,ndxn);
f5 = X1(( ndxm.*cos(1)+ndxn.*sin(1) ), ( ndxm.*sin(1)+ndxn.*cos(1) ));
f6 = X1(( ndxm.*cos(-1.)+ndxn.*sin(-1) ), ( ndxm.*sin(-1)+ndxn.*cos(-1) ));
end
end
Thank you!!

채택된 답변

Image Analyst
Image Analyst 2013년 4월 17일
Take the semicolons off these lines
ndxm = 1+delta:fm-delta
ndxn = 1+delta:fn-delta
so you'll see their values. Then go to this link.
  댓글 수: 1
Brandon
Brandon 2013년 4월 17일
Thank you I figured it out with your help! I was going about it all wrong... figures!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by