Alternative function or tool instead of plot or line ?

조회 수: 25(최근 30일)
Redwan Dan
Redwan Dan 2016년 4월 8일
편집: Walter Roberson 2016년 4월 9일
function for drawing segment between three points in set of points (to make triangle that capture all other set of point inside it) but without using plot or line function any other function because those two function not draw at accurate coordinates ?
note / those set of points are random in x,y coordinates, and the three points i denote it like stars.
appreciate any help and i will be thankful.
ܪܝܕܘܐܢ
  댓글 수: 7
Redwan Dan
Redwan Dan 2016년 4월 8일
% define values
a = [17 14 2 15 16 12 17 8 12 10; 13 1 12 12 9 6 14 8 9 10 ];
for j=1:10
if(a(1,j)==a(1,p)&a(2,j)==a(2,q))
scatter(a(1,j),a(2,j),'*')
else
scatter(a(1,j),a(2,j),'o')
hold on
end
end
p0=[a(1,7),a(2,7)]
scatter(xmax(1)+5,ylow-10,'*')
px = (xmax(1)+5)
py =(ylow-10)
p1= [px,py]
scatter(xlow-10,ymax,'*')
ppx = (xlow-10)
ppy = ymax
p2=[ppx,ppy]
plot(p1,p2)
plot(p1,p0)
plot(p2,p0)
% plot([px,py],[ppx,ppy])
% plot([px,py],p0)
% plot([a(1,p),a(1,q)],[ppx,ppy])
% line([a(1,p),a(1,q)],[a(1,6),a(2,6)])

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

채택된 답변

Ced
Ced 2016년 4월 8일
편집: Ced 2016년 4월 8일
Hi
I think you misunderstood the plot function. The first argument are all the x values, and the second argument are all the y values. What you are plotting with plot(p1,p2) is actually ( p1(x), p2(x) ) and (p1(y), p2(y)), which is not what you want.
In this case plot should be
plot([ px ppx ],[py ppy])
The same goes for the line function, which is probably why it seemed to return garbage. The syntax is
line([ x1 x2 ],[ y1 y2 ]); % NOT line([ x1 y1 ],[ x2 y2 ])!
Your max computation does not make much sense to me. Every time you find a new maximum, you write it to xmax(l+1) (which is xmax(2)), but then compare xmax again? There is a max function... why not use it?
And yes, please paste the complete code (as in text copy-paste, not as in picture paste) in your questions so that people can run the code and actually try to see what's wrong.
  댓글 수: 2
Redwan Dan
Redwan Dan 2016년 4월 8일
px0 = a(1,7)
py0=a(2,7)
plot([ px ppx ],[py ppy])
plot([px0 px],[py0 py])
plot([px0 ppx],[py0 ppy])

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by