how i do plot a point connecting 5 points and how i name the end point and centre point with letters

2 vues (au cours des 30 derniers jours)
how i can draw the graph and name the end points with letters?

Réponse acceptée

Meg Noah
Meg Noah le 10 Jan 2020
Here's a solution
% your data
x = [20 25 30 35 45];
y = [40 15 10 50 30];
x0 = 30;
y0 = 30;
figure('color','white');
xlim([20 45]); ylim([10 50]);
hold on;
for ipt = 1:length(x)
plot([x(ipt) x0],[y(ipt) y0],'color',[0 0 1]);
myChar = char(64+ipt);
text(x(ipt)+0.5,y(ipt)+0.75,myChar);
end
plot(x,y,'o','markerfacecolor','k','markeredgecolor','none', ...
'markersize',4);
plot(x0,y0,'o','markerfacecolor','k','markeredgecolor','none', ...
'markersize',4);
text(x0+0.5,y0+0.75,'O');
set(gca,'xtick',[20:2:44]);
set(gca,'ytick',[10:10:50]);
set(gca,'XMinorTick','on');
set(gca,'YMinorTick','on');
xlabel('x');
ylabel('y');
plottyplot.png
  3 commentaires
Meg Noah
Meg Noah le 11 Jan 2020
This is how to find the point. What do you mean by 'animate' it? Are you looking for an animated gif output? or mp4?
fun = @(p) sum(sqrt((p(1)-x).^2 + (p(2)-y).^2));
p0 = [x0 y0];
[p] = fminsearch(fun,p0);
disp(['minimized O = [' num2str(p(1)) ',' num2str(p(2))]);
jakaria babar
jakaria babar le 11 Jan 2020
yes . i want to make an animated mp4 for the graph.
thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by