cannot get the title and xlabel plotted in a while loop
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am using the following code to update the vertical positions on a figure plot of a target marker(p1), joystick marker(p2), and a connecting line between both(p3). I would like to also display the time as title and the position coordinates as xlabel. It worked last week, I don't remember what I changed/deleted since then, but I can't fix it now/ realize what the issue is ? Any suggestions ? Thanks in advance !
k = 1;
while k <= 1000
Y = -(axis(joy, 2));
set(p1,'YData',y1_shifted_abs(k));
set(p2,'YData',Y);
set(p3,'YData',[y1_shifted_abs(k) Y])
time = datestr(now);
title(strcat('Clock time: ',time(end-7:end)));
xlabel({strcat('Target position: ',' ',num2str(y1_shifted_abs(k)));strcat('Joystick position: ',' ',num2str(Y));strcat('\bf Gap: ',' ',num2str(abs(y1_shifted_abs(k) - Y)))});
drawnow
k = k + 1;
end
0 commentaires
Réponses (2)
Pritesh Shah
le 5 Oct 2016
Give error message.
Y = -(axis(joy, 2)); it should be,
Y = -(axis([joy, 2]));
2 commentaires
Jan
le 5 Oct 2016
Do you get an error message? Do the results differ from your expectation? Please mention the problem you have.
I think this is nicer:
xlabel({sprintf('Target position: %g', y1_shifted_abs(k)); ...
sprintf('Joystick position: %g', Y); ...
sprintf('\bf Gap: %g', abs(y1_shifted_abs(k) - Y))});
but I do not see a connection to a problem.
Voir également
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!