At Image or others: Distance from points to point.
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
채택된 답변
Image Analyst
2014년 2월 9일
I thought I already showed you in your duplicate question http://www.mathworks.com/matlabcentral/answers/115335#comment_195217. I don't know what gplot() is - I never use it. I showed you how you could use plot() to pass in a color. You just need to assign the color. For example
if distance > gvar(i)
plot(x,y, 'ro-'); % Plot red circles.
else
plot(x,y, 'bs-'); % Plot blue squares.
end
By the way, your loop over i and j is calculating all the distances twice, unlike how I showed you. The distance from point 1 to point 3 is the same as from point 3 to point 1 so why calculate it again?
댓글 수: 6
But If you note, with the plot command you delete the square. I do not want this. I do not want to delete the square that contains the coordinates of points. The distances between the various coordinates are already in memory. I just want to highlight those I am interested to .With the plot command you eliminate the spatial information of where these points are contained in the square.
Fine. Keep them if you need them later. It's only a few points so it won't take any time at all. The comparison of the distance to the gvar distances to determine color still holds though, don't you agree? To determine a color like you want, you MUST compare the distance to the distances associated with each color. There is no other way. How else will you know what color to use?
The question of color is not important because it is related in the values of the variable val_mag. You have to consider this: The first value of val_mag is the distance between 0.2 and 0.3 to 0.7 and 0.4. The second value of the val_mag variable is associated with the distance between 0.2 and 0.3, to 0.45 and 0.37. The third value of the val_mag variable is associated with the distance between 0.2 and 0.3 and 0.1 and 0.6 and so on. All these distance have to point out in red. The others distances don't matter. You know what distances should be highlighted in red because this information is contained in the element of val_mag greater than zero. Is not clear?
>> val_mag
val_mag =
0.3366
0
0.1766
It's not clear why you can't adapt my answer to get it to work. Why can't you just isert this code and have it work:
if dist(i,j) > val_mag(i) % or gvar - whatever it's called.
plot(x,y, 'ro-'); % Plot red circles.
else
plot(x,y, 'bs-'); % Plot blue squares.
end
You just figure out what x and y are for the pair of points you're considering and draw the correct color.
??? Attempted to access val_mag(9); index out of bounds because numel(val_mag)=3.
Now there is this error code line.
Well how did the index get to 9? Are you using the debugger at all? Or just wanting me to download your code and data and have me debug it for you?
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
