How do I display variable values on my figure window???
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is my code so far. It basically changes the location of an image based on how many times I press the arrow key. All I want to do is display the variable values d and p in the figure window that pops up.
d = 20
p = 20
f = figure;
k=1;
while k
waitforbuttonpress;
if get(gcf,'CurrentCharacter')==28 %left arrow key
d=d-10
elseif get(gcf,'CurrentCharacter')==29 %right arrow key
d=d+10
elseif get(gcf,'CurrentCharacter')==31 %down arrow key
p=p-10
elseif get(gcf,'CurrentCharacter')==30 %up arrow key
p=p+10
elseif get(gcf,'CurrentCharacter')==32 %space bar
break
end
cla reset
axis([-400,400,-200,200]);
hold on
ax = gca;
ax.XTick = [];
ax.YTick = [];
ax.DataAspectRatioMode = 'manual';
ax.DataAspectRatio = [1 1 1];
ax.PlotBoxAspectRatioMode = 'manual';
ax.PlotBoxAspectRatio = [1 1 1];
img = imread('eyechart1.jpg');
image([d -p],[d -p],img);
end
I would like to display the d and p variable values on the figure window. What syntax would I use for this? Thanks!!!!
0 commentaires
Réponses (1)
Image Analyst
le 24 Oct 2016
Try title()
caption = sprintf('d = %d, p = %d', d, p);
title(caption, 'FontSize', 20);
0 commentaires
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects 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!