I have 2 data vectors, where the data comes from Arduinos until everything is fine there. I graph the points and everything is fine. What happens is that when I want those points to have a line, that is, a trend line, a line that passes through all these points is not plotted. I do not understand why? I mean the points are only plotted, but the line is not plotted. Thanks for reading me
ANNEX CAPTURE URL OF HOW SHOULD BE LEFT(https://twitter.com/EH_38/status/1201419564661248000/photo/1)
ANNEX CAPTURE URL OF HOW I GET MY GRAPH IN SCRIPT(https://twitter.com/EH_38/status/1201420265466531840/photo/1)
<<<CODE>>>
function arduinomatlab
n=21
v1=zeros(1,1000);
v2=zeros(1,1000);
delete(instrfind({'Port'},{'COM3'}));
s = serial('COM3','BaudRate',9600,'Terminator','CR/LF');
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
fopen(s);
muestras=1;
figure('Name','Captura');
xlabel('Tiempo')
ylabel('Aceleracion')
title('Acelerograma')
grid on
hold on
while 1<=n
ylim([0 240]);
xlim([0 0.5]);
valor=fscanf(s, '%f,%f')';
v2(muestras)=(valor(2));
v1(muestras)=(valor(1));
plot(v2(muestras),v1(muestras),'x-')
drawnow
muestras=muestras+1;
end
fclose(s);
delete(s);
clear s;
end
Best Answer