I am creating and app which can plot live data from Ultrasonic sensor to UIaxis, I am able to plot the data point with any other shapes like square, circle or star, but not the continues line which I want. can someone help me with this? I am attaching my code.

 채택된 답변

Voss
Voss 2023년 9월 28일

1 개 추천

What you have now is
plot(app.UIAxes,app.t,app.y,'bs');
which plots blue squares at the points given by (app.t,app.y).
If you change it to
plot(app.UIAxes,app.t,app.y,'-bs');
then that would plot blue squares at the points (app.t,app.y) with a solid blue line connecting them.
Or perhaps you want:
plot(app.UIAxes,app.t,app.y,'-b');
% or simply
plot(app.UIAxes,app.t,app.y,'b');
which would plot a solid blue line with no squares (or markers of any kind).
See:
for other line style/marker/color options.

댓글 수: 4

Dhrumit
Dhrumit 2023년 10월 2일
Thank you for response, the issue is it is showing only one data point at a time and that's why I am not able to plot the line. Any sugestion on this?
function StartbuttonButtonPushed(app, event)
app.y = [];
app.t = [];
i = 1;
start = tic();
cla(app.UIAxes,'reset');
app.UIAxes.YLim = [0 20];
while true
app.y(i) = 100 * app.arduino_pinwrite.readDistance();
app.t(i) = toc(start);
plot(app.UIAxes,app.t,app.y,'-bs');
drawnow();
if app.Stop == true
break;
end
i = i+1;
end
end
Dhrumit
Dhrumit 2023년 10월 11일
It works now. Thank you for providing me the sollution.
Dyuman Joshi
Dyuman Joshi 2023년 10월 11일
Hello @Dhrumit, if this answer solved your problem, please consider accepting the answer.
Accepting the answer indicates that your problem has been solved (which can be helpful to other people in future) and it awards the volunteer with reputation points for helping you.
You can accept only 1 answer for a question, but you can vote for as many answers as you want. Voting an answer also provides reputation points.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 9월 28일

댓글:

2023년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by