Alternative function or tool instead of plot or line ?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Redwan Dan
am 8 Apr. 2016
Bearbeitet: Walter Roberson
am 9 Apr. 2016
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160506/image.jpeg)
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 Kommentare
Adam
am 8 Apr. 2016
Bearbeitet: Adam
am 8 Apr. 2016
I don't have to time to look through carefully, but you need to check your maths and put breakpoints in at the points you are about to plot and check whether your p1, p2, p0 values are correct.
It is almost certain that it is your maths to create those points that is wrong, not the plot function.
As an aside for better code understandability and to hopefully produce fewer bugs though I would not recommend embedding maths directly in the call to scatter. Create your data first and store it, then call scatter on that data. Then the points you need to plot should be points within that stored data rather than you having to try to apply the same maths for the end points of the line that you already did when calling scatter.
Akzeptierte Antwort
Ced
am 8 Apr. 2016
Bearbeitet: Ced
am 8 Apr. 2016
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!