Borrar filtros
Borrar filtros

Getting the X and Y coordinates of the points from the figure

14 visualizaciones (últimos 30 días)
kaivlya patel
kaivlya patel el 20 de Mayo de 2020
Comentada: Image Analyst el 21 de Mayo de 2020
Hi all,
I am running a code and at the end, the figure is generating with the points. The detail description and the figure is attached below:
Here, I want to calculate the distace of all the red dots from the green Utopia star. And for that, I want to get the the X and Y coordinates of all the red dots. I am also attaching the code for this figure here:
%Plotting the tradespace and pareto frontier with corresponding architectures
Utopia = UtilityHighRange; % for plotting purposes add Utopia point
plot(archs_cost(1),archs_util(1),'b.','Tag',sprintf('ix %d\n%s',1, join(archs(1,:))) )
hold on % moved up from below
for n = 2:n_arch
plot(archs_cost(n),archs_util(n),'b.','Tag',sprintf('ix %d\n%s',1, join(archs(n,:))) )
end
datacursormode on
dcm = datacursormode(gcf);
set(dcm,'UpdateFcn',@myupdatefcn)
xlabel('Cost')
ylabel('Utility')
xlim([CostLowerRange CostHighRange])
ylim([UtilityLowerRange UtilityHighRange])
title('Trade Space Pareto')
hold on
plot(Utopia,'pg','LineWidth',5)
annotation('textarrow',[0.1657 0.1357],[0.8738 0.9238],'String','Utopia')
plot(pareto_frontier(1, 2), pareto_frontier(1, 3), 'rs', 'LineWidth', 3, 'Tag', sprintf('ix %d\n%s', 1, join(pareto_frontier_archs(1, :))))
hold on
for n = 2:frontier_idx
plot(pareto_frontier(n:frontier_idx, 2), pareto_frontier(n:frontier_idx,3), 'rs', 'LineWidth', 3, 'Tag', sprintf('ix %d\n%s', 1, join(pareto_frontier_archs(n, :))))
end
datacursormode on
dcm = datacursormode(gcf);
set(dcm, 'UpdateFcn', @myupdatefcn)
hold off
In here, the red dots shows the pareto_frontier points into the figure. The coordinates are getting generated into the figure for all the red dots, however I would like to print all the coordinates in the command window. I have also used the handle, get(pareto_frontier, 'XData'), but it is not generating the result.
Any help in this perticular will be highly appreciated and I would be really greatful for it as I am in a urgent need of this solution.
Thank you.

Respuestas (1)

Image Analyst
Image Analyst el 20 de Mayo de 2020
Why can't you just use fprintf():
for k = 1 : length(pareto_frontier(:, 2))
fprintf('x = %f, y = %f.\n', pareto_frontier(k, 2), pareto_frontier(k, 3));
end
  3 comentarios
kaivlya patel
kaivlya patel el 20 de Mayo de 2020
one last thing I would like to know, how can I export this x and y coordintes value to the excel file using writematrx command?
Image Analyst
Image Analyst el 21 de Mayo de 2020
xy = [pareto_frontier(:, 2), pareto_frontier(:, 3)];
writematrix(xy,'pareto_frontier.xlsx');

Iniciar sesión para comentar.

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by