Borrar filtros
Borrar filtros

It seems that PLOT command is being bypass and not being execute..

1 visualización (últimos 30 días)
delete(instrfindall)
clear all;clc
s = serial('COM6');
fopen(s)
A1 = 0; B1 = 0;
for i = 1:1000
P = fscanf(s,'%f')
if P == 1
A1 = A1+1; B1 = B1;
elseif P == 2
A1 = A1-1; B1 = B1;
elseif P == 3
A1 = A1; B1 = B1+1;
elseif P == 4
A1 = A1; B1 = B1-1;
else
end
plot(A1,B1,'*')
hold on
end
fclose(s)
delete(instrfindall)
I have written this code. I am receiving serially data very wel . But plot command is not being executed. As well * is not moving accordingly. Please correct me.

Respuesta aceptada

Image Analyst
Image Analyst el 14 de Mayo de 2016
A1 and B1 are just points, not vectors or arrays. So you will just see a single point, not a curve. To see it better, try this:
plot(A1, B1, 'b*', 'LineWidth', 2, 'MarkerSize', 30);
grid on;
If you want more points, then you need to make A1 and B1 vectors, or else put "hold on" and call plot over and over again with new values of A1 and B1.
  6 comentarios
Walter Roberson
Walter Roberson el 15 de Mayo de 2016
Good point about the drawnow()
Nimisha
Nimisha el 16 de Mayo de 2016
Editada: Nimisha el 16 de Mayo de 2016
Thanks.
drawnow
Commmand works well to show and update plot.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 14 de Mayo de 2016
After the
hold on
add
set(gca, 'xlimmode', 'auto', 'ylimmode', 'auto')
  1 comentario
Nimisha
Nimisha el 15 de Mayo de 2016
Ya. Thanks I modified my code with this command.
But my actual problem is mentioned above.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by