Afficher commentaires plus anciens
Hi,
I've got a figure with several subplots. These subplots are located one under the other one. Then, that I want to do is create a vertical cursor to across all subplots and when I'm going to move this appear the current values of all subplots.
How can I develop this?
thanks
regards
Réponse acceptée
Plus de réponses (3)
Brett Shoelson
le 14 Fév 2011
1 vote
Jiro Doke
le 22 Fév 2011
1 vote
Paulo Silva
le 14 Fév 2011
You might find useful tips inside the ginput function
edit ginput
%this function can be found inside ginput
set(fig,'pointer','fullcrosshair'); %horizontal and vertical cursor lines
9 commentaires
Mtlb Usr
le 14 Fév 2011
Paulo Silva
le 14 Fév 2011
for the cursor lines you just need
set(fig,'pointer','fullcrosshair');
fig is the handle for the figure, you can use gcf instead of fig (fig=figure), gcf give the handle of the current figure
for the cursor position inside the figure you can do
get(gcf,'currentpoint')
for the cursor position inside an axis you can use the ginput, it will give you x,y and the button pressed, that's why I told you to look at the ginput code.
Mtlb Usr
le 14 Fév 2011
Paulo Silva
le 14 Fév 2011
Here's one example, it allows you to mark points of several subplots, the coordinates and button pressed is shown on the command line.
subplot(311)
hold on
subplot(312)
hold on
subplot(313)
hold on
but=1;
while ((but==1))
[x,y,but]=ginput(1)
plot(x,y,'*')
end
Paulo Silva
le 14 Fév 2011
Another version, now the subplots have different and fixed limits, also the point only gets marked when you press the mouse left button.
subplot(311)
hold on
axis([0 100 -10 10])
subplot(312)
hold on
axis([-100 100 -20 10])
subplot(313)
hold on
axis([100 200 -10 20])
but=1;
while ((but==1))
[x,y,but]=ginput(1)
if but==1
plot(x,y,'*')
end
end
Paulo Silva
le 14 Fév 2011
if you want to save the coordinates pressed
but=1;xv=[];yv=[];
while ((but==1))
[x,y,but]=ginput(1)
if but==1
xv=[xv x];yv=[yv y];
plot(x,y,'*')
end
end
plot(xv,yv) %you can connect the dots marked
Mtlb Usr
le 14 Fév 2011
Paulo Silva
le 14 Fév 2011
I'm finally understanding but what you want isn't easy, at least for me and my basic matlab skills, maybe someone with more experience might help you.
Here's some websites with info, maybe you can find something useful in them
http://matlab.wikia.com/wiki/MATLAB_Wiki
http://undocumentedmatlab.com
Mtlb Usr
le 15 Fév 2011
Catégories
En savoir plus sur Data Exploration dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!