How to make plot with enter the coordinate

I want to make a plot with coordinate.
Starting the plot I want to get the exact coordinate.
Is there any mathod with keyboard?

12 件のコメント

Jan
Jan 2021 年 3 月 23 日
The question is not clear yet. A coordinate of what? On the earth, on the monitor, in an axes?
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
disp('Initial location of particles')
lon0=[];
lat0=[];
for i=1:pn
title(['Click initial position of particle #' num2str(i)])
[loni lati]=ginput(1);
lon0=[lon0 loni];
lat0=[lat0 lati];
plot(loni,lati,'ko','markerfacecolor','k')
end
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
not using mouse
I want to use keyboard and directly input the coordinates
Geoff Hayes
Geoff Hayes 2021 年 3 月 23 日
But what do you want to do with those coordinates that you input with the keyboard? Is that where you call
plot(loni,lati,'ko','markerfacecolor','k')
where you want the loni and lati to be the longitude and latitude that the user enters?
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
I want to enter (35,131)
Geoff Hayes
Geoff Hayes 2021 年 3 月 23 日
You may want to try using the inputdlg to capture the input and then process it.
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
umm.. It doesnt' work.
Geoff Hayes
Geoff Hayes 2021 年 3 月 23 日
You may want to show what you have attempted and clarify what you mean by "It doesn't work".
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
Inputdlg is not working that I want to input coordinates.
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
Is there a way to take the coordinates I want?
Geoff Hayes
Geoff Hayes 2021 年 3 月 23 日
If you want to enter the coordinates you want and then do something with them, you could try
prompt = {'Enter latitude (degrees):','Enter longitude (degrees):'};
dlgtitle = 'Input coordinates';
answer = inputdlg(prompt,dlgtitle)
latitude = str2double(answer{1});
longitude = str2double(answer{2});
% do whatever checks you need here for valid latitude and longitudes
if abs(latitude) > 90
latitude = mod(latitude,90);
end
if abs(longitude) > 180
longitude = mod(longitude,180);
end
fprintf('latitude is: %f\n', latitude);
fprintf('longitude is: %f\n', longitude);
But it still isn't clear to me that this is really what you are asking for.
gyeonggeun kim
gyeonggeun kim 2021 年 3 月 23 日
Thank you very much! I will try it

サインインしてコメントする。

回答 (0 件)

タグ

質問済み:

2021 年 3 月 23 日

コメント済み:

2021 年 3 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by