Please Help me with my code (Index exceeds matrix dimensions)

2 ビュー (過去 30 日間)
Samuel Halle
Samuel Halle 2018 年 4 月 14 日
回答済み: Walter Roberson 2018 年 4 月 14 日
I am not very good at explaining my problems so I will post the relevant parts of the code and the error message below and hope that someone can help. The error occurs in the 2nd to last line of code that I posted below. When I comment this line out the rest of the code runs flawlessly.
start1=400
start2=531
start3=663
start4=781
finish4=890
start1new = (start1*1800/120)
start2new = (start2*1800/120)
start3new = (start3*1800/120)
start4new = (start4*1800/120)
finish4new = (finish4*1800/120)
%Filtering EMG Data
[B,A]=butter(2,(2*30/1800),'high');
filtEMGdata = filtfilt(B,A,rawEMGdata);
filtEMGdata = abs(filtEMGdata);
[B,A]=butter(2,(2*10/1800),'low');
filtEMGdata=filtfilt(B,A,filtEMGdata);
%Normalized EMG Brackets
normGas_Med_EMG = [];
normGas_Lat_EMG = [];
normTA_EMG = [];
normPer_Long_EMG = [];
normSol_EMG = [];
%Normalized EMG data
normGas_Med_EMG(:,1) = downsample(interp(filtEMGdata(start1new:start2new,1),200),length(start1new:start2new));
normGas_Med_EMG(:,2) = downsample(interp(filtEMGdata(start2new:start3new,1),200),length(start2new:start3new));
normGas_Med_EMG(:,3) = downsample(interp(filtEMGdata(start3new:start4new,1),200),length(start3new:start4new));
aveGas_Med_EMG = mean(normGas_Med_EMG,2);
Here is the Error Message:
Index exceeds matrix dimensions.
Error in AnkleTapingStudy_EMG_CODE_2 (line 147)
normGas_Med_EMG(:,3) = downsample(interp(filtEMGdata(start3new:start4new,1),200),length(start3new:start4new));
I am confused because the first 2 lines under "Normalized EMG Data" work, but the 3rd does not. Why is this?
p.s. When I set "start4" to 697 the code runs, but anything greater or equal to 698 is an error message. The relevant information in my data is at frame 781. What should I do?
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 4 月 14 日
What is size(rawEMGdata)
Samuel Halle
Samuel Halle 2018 年 4 月 14 日
10467 units long. That's why I'm filtering it down to make it easier to read.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 4 月 14 日
1800/120 = 15, so you are working with blocks of 15 samples per "start" value.
10467/15 = 697.8, so any "start" value greater than 697, when multiplied by 1800/120, is going to result in trying to index outside the data.
If you hope to reach 890 as the finish then your blocks cannot be more than 11 rather than 15.

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by