Index exceeds matrix dimensions

clear all
close all
x1 = fopen('100.dat'); % load the ECG signal from the file
fs = 200; % Sampling rate
N = length (x1); % Signal length
t = [0:N-1]/fs; % time index
figure(1)
subplot(2,1,1)
plot(t,x1)
xlabel('second');ylabel('Volts');title('Input ECG Signal')
subplot(2,1,2)
plot(t(200:600),x1(200:600))
xlabel('second');ylabel('Volts');title('Input ECG Signal 1-3 second')
xlim([1 3])
The plot window opens but there is no waveform plotted and the following error shows,
Index exceeds matrix dimensions.
Error in Untitled6 (line 15)
plot(t(200:600),x1(200:600))
Kindly help!!!

댓글 수: 5

Murugan C
Murugan C 2020년 2월 27일
attach your dat files,
Pooja
Pooja 2020년 2월 27일
i cannot attach the .dat file says it is unsupported format here.
Ankit
Ankit 2020년 2월 27일
you can save it as *.mat file (e.g. x1)
Adam
Adam 2020년 2월 27일
Isn't the error self-explanatory? Either t or x1 (in this case both, since t is sized based on x1) do not have indices up to 600 - i.e. their size is < 600. If you step through the code with the debugger you will instantly see what the problem is here. Either you need x1 to be longer or you need your indices to be less so that they access data that actually exists in x1.
Pooja
Pooja 2020년 2월 27일
Okay thanks!

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2020년 2월 27일

댓글:

2020년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by