cannot get the title and xlabel plotted in a while loop
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Pritesh Shah
2016-10-5
Give error message.
Y = -(axis(joy, 2)); it should be,
Y = -(axis([joy, 2]));
Jan
2016-10-5
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!