필터 지우기
필터 지우기

what am i doing wrong here? Invalid expresssion!

조회 수: 1 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 11월 19일
댓글: muhammad choudhry 2020년 11월 19일
Hi,
I am trying to loop over the code below.
co_ordinates = 102 x 1 double
Indices = 17 x 1 double
code to extract the single value is
XY = co_ordinates (indices(1)+1:indices(2)-1,1)
how can I perform the loop over above line ?
So far I tried!
for i =1:length(co_ordinates)
XY(i) = coordinates(i) (indices(1)(i)+1:indices(2)(i)-1,1(i))
end
but I am getting an error: Invalid expression in the line
  댓글 수: 1
David Hill
David Hill 2020년 11월 19일
Show us an example of what you want XY to be from your other two arrays.

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

답변 (1개)

Image Analyst
Image Analyst 2020년 11월 19일
편집: Image Analyst 2020년 11월 19일
You have extra things in () after the variable names. Get rid of those. And you mispelled co_ordinates inside the loop. Try this:
for k = 1 : length(co_ordinates)
XY(k) = co_ordinates(indices(k)+1 : indices(k)-1, k)
end
but indices(k)+1 : indices(k)-1 will be null unless the indices are negative values since you're going from a high value to a low value. Maybe you wanted
for k = 1 : length(co_ordinates)
XY(k) = co_ordinates(indices(k)-1 : indices(k)+1, k)
end
But that would give a range of values for the first index, and you can't stuff a vector into the single element of XY. It's hard to know you really want/need without you actually describing more what "Extract the single value" means to you.
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 11월 19일
yes sir
muhammad choudhry
muhammad choudhry 2020년 11월 19일
Please find the attach! I have modify the code but I am still getting error it is because i used i+1 in the code and at the final value it is still adding 1....... I am not sure how to get this right....
What code is doing:
reading the image extracting contours C values, base on the vertices in it I am extracting the contours arrays hence would like to do in a way it will save the arrays of all contours separtely. I have attached the frame and code here

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

Community Treasure Hunt

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

Start Hunting!

Translated by