Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Why does it tell me that it exceeded the array? if you have more than what it supports in graphics?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Why does it tell me that it exceeded the array? I don't understand if I put more than 1000
I leave the error message that matlab tells me
<<<Error message>>>
Index exceeds matrix dimensions.
Error in arduinomatlab (line 29)
v1(muestras)=(valor(1));
<<Error message>>
<<CODE>>
function arduinomatlab
global v1 v2
v1=zeros(1,100000);
v2=zeros(1,100000);
n=10;
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('Muestras')
ylabel('Voltaje (V)')
title('Captura de voltaje en tiempo real con Arduino')
grid on
hold on
while muestras<=n
ylim([0 15]);
xlim([muestras-10 muestras+10]);
valor=fscanf(s, '%d,%d')';
v1(muestras)=(valor(1));
v2(muestras)=(valor(2));
plot(muestras, v1(muestras),'*-b');
plot(muestras, v2(muestras),'*-r');
drawnow
muestras=muestras+1;
end
fclose(s);
delete(s);
clear s;
end
0 Kommentare
Antworten (1)
Walter Roberson
am 2 Dez. 2019
max_error = 10;
error_count = 0;
while muestras<=n && error_count < max_error
ylim([0 15]);
xlim([muestras-10 muestras+10]);
thisline = fgetl(s);
valor = sscanf(thisline, '%d,%d')';
if length(valor) < 2
error_count = error_count + 1;
fprintf('warning #%d, line with unexpected content: "%s"\n', error_count, thisline);
else
v1(muestras)=(valor(1));
v2(muestras)=(valor(2));
plot(muestras, v1(muestras),'*-b');
plot(muestras, v2(muestras),'*-r');
drawnow
muestras=muestras+1;
end
end
if error_count >= max_error
fprintf('Gave up because of too many errors on input\n');
end
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!