Clear Filters
Clear Filters

EMG signal processing ADC plot showing error .

1 view (last 30 days)
when i try process the acquired EMG signal i cant get the ADC PLOT.
when i try to run it shows the error (below mentioned inside the double quotation block letters)
"Index exceeds the number of array elements. Index must not exceed 15153.
Error in Main_Code_REVISED (line 38)
plot(t, xt(1:40000), 'b.-','LineWidth', 2,'MarkerSize', 15);% plot the signal
>> "
Here i added the code for reference
%% ------------------------------------------------ ****** ADC At Sample Rate ****** ---------------------------------------%
% Sampling rate is 400 Hz, or one sample every 1/400 of a second.
% Number of Samples = (elasped time) / (time per sample)
numSamples = round(10^2/(1/400)); % Round towards nearest integer.
% That is only 40000 and gives a severe undersampling of the signal
% giving a weird shape.
t = linspace(0, 0.1, numSamples);%generates N points between X1 and X2.
xt = filtered_sig1; % Assigned bpf output signal
figure(3)% open a figure in new window
plot(t, xt(1:40000), 'b.-','LineWidth', 2,'MarkerSize', 15);% plot the signal
grid on;% adds major grid lines to the current axes.
title('sampling Interval'); % Graph title
xlabel('t'); % X-axis label.
ylabel('x(t)');% Y-axis label.

Answers (1)

Sai Pavan
Sai Pavan on 18 Oct 2023
Hi Athikesavan,
I understand that you are trying to resolve the error encountered when plotting the filtered signal.
The "Index exceeds the number of array elementserror suggests that the index used for slicing the xt array exceeds the number of elements in the array. The error message indicates that there are only 15153 samples stored in the variable “xt, but you are trying to access elements up to index 40000.
The two arguments of the “plot” function must be of the same size. The error can therefore be resolved either by collecting more samples (numSamples) up to 40000 or, by slicing the “t (sampling time) array to 15153 samples and then plotting the signal so that the two arguments of the function match.
Please refer the below documentation to learn more about “plot” function: https://www.mathworks.com/help/matlab/ref/plot.html
Hope it helps.
Regards,
Sai Pavan

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!