필터 지우기
필터 지우기

Hi I hope are well, I am making a serial interface for communication between C and matlab Pic by Proteus, but I get this error because it can be?

조회 수: 1 (최근 30일)
??? Attempted to access c(1); index out of bounds because numel(c)=0.
Error in ==> trabajopractico at 139 y(contador_ECG)=(c(1))*5/1024; and the code:
function trabajopractico(numero_Muestras)
close all;
clc;
n=207300;
y=zeros([1 n]); %%Vector donde se guardaran los datos
for i = 1:n, y(i) = i; end
delete(instrfind({'Port'},{'COM1'}));
PIC16F877A=serial('COM1'); %%vector para la comunicación serie
PIC16F877A.BaudRate=9600; %%velocidad en baudios
PIC16F877A.DataBits=8; %%Bits de datos igual a 8
PIC16F877A.StopBits=1; %%un bit de parada
warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
fopen(PIC16F877A); %%Abre el puerto
contador_ECG=1;
msgbox('Recibiendo Señal ECG...');
%%Ventana para la Grafica PROTEUS:ECG
figure('Name','PROTEUS: SEÑAL ECG');
title('PROTEUS: SEÑAL ECG');
xlabel('Número de Muestras');
ylabel('Amplitud');
grid;
%%Bucle While para que tome y grafique las Muestras
while contador_ECG<=numero_Muestras
ylim([0 5.1]); %Limites del eje y
xlim([contador_ECG-20 contador_ECG+200]); %Limites del eje x
c=fscanf(PIC16F877A,'%d')'; %Toma el valor recibido por el puerto y lo guarda en la variable
y(contador_ECG)=(c(1))*5/1024;
plot(contador_ECG,y(contador_ECG),'X-r'); %Grafica el potencial_A
drawnow
contador_ECG=contador_ECG+1;
end
%%Cerrando el Puerto...
fclose(PIC16F877A);
delete(PIC16F877A);
clear all;

답변 (1개)

Stalin Samuel
Stalin Samuel 2016년 6월 11일
  • The variable 'c'not having even a single element
  • Make sure that 'c' receive the signal from Pic
  댓글 수: 1
NiyuB
NiyuB 2016년 6월 12일
thanks, good that the c variable must be in the programming of Pic c, is what you say? really I could not fix it, that error may be because since the pic is not receiving?

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by