I'm trying to get the EMG reading in graph form from this file, I was able to get a graph but it looks zoomed out?

3 views (last 30 days)
EDIT: fixed your code so that it runs here
S= load('Exercse 1.mat');
plot(S.data, 'b', 'DisplayName', 'File 2');

Answers (1)

dpb
dpb on 17 Mar 2025
Edited: dpb on 19 Mar 2025
S= load('Exercse 1.mat');
S
S = struct with fields:
data: [2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 2.2156e-05 ... ] (1x65044 double) datastart: [4x3 double] dataend: [4x3 double] titles: [4x11 char] rangemin: [4x3 double] rangemax: [4x3 double] unittext: 'V' unittextmap: [4x3 double] blocktimes: [7.3967e+05 7.3967e+05 7.3967e+05] tickrate: [200 200 200] samplerate: [4x3 double] firstsampleoffset: [4x3 double] comtext: 'weight' com: [3x5 double]
There are a bunch of other data associated with the .mat file that look as though some of those are sampling time related, but we don't know what, specifically, they mean. Things could look different if plotted against actual time as opposed to just against the ordinal index of the observation.
Then again, it well may be you're supposed to be looking only at a specific region in the trace; we have no klew as to what the Exercise objective(s) may be besides not knowing about the details of the data file itself...
S.datastart
ans = 4×3
1 12509 26097 3128 15906 35834 6255 19303 45571 9382 22700 55308
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
S.dataend
ans = 4×3
3127 15905 35833 6254 19302 45570 9381 22699 55307 12508 26096 65044
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
S.titles
ans = 4x11 char array
'RMS Biceps ' 'RMS Triceps' 'Biceps ' 'Triceps '
From the above, it appears there are four separate recordings here and, it looks like, probably three separate measurements of each defined by those starting and ending points in the overall trace.
Just for starters, something like
M=height(S.datastart); % number of separate traces
for i=1:M
subplot(M,1,i) % create a separate axes for each
i1=S.datastart(i,1); % starting point in trace
i2=S.dataend(i,1); % ending point
N=i2-i1+1; % number points in trace
plot(S.data(i1:i2),'displayname',strtrim(S.titles(i,:))) % titles are fixed-length char() arrays
xlim([0 N]) % expand to fit axes width
legend
end
provides a set of traces that look to be stationary appropriate for analyses; still plotted against the ordinal observation as didn't look into the sampling time data to use it to create the time trace(s)...it appears there may be differences there; at least there are multiple values. This also only looks a the first set of the three...
You'll need to read carefully the instructor's notes that must have come with the dataset to fully understand the datasets provided and how to interpret the rest of the information.
Let's see where these are on the original figure...
figure
plot(S.data)
xlim([0 numel(S.data)])
hold on
C='grcm'; % the color mnemonics
T=width(S.datastart); % number of repitions it appears?
for i=1:M % for each measurement type
for j=1:T % for each measurement of the given type
i1=S.datastart(i,j);
i2=S.dataend(i,j);
plot(i1:i2,S.data(i1:i2),'color',C(i),'linestyle','-')
end
end
From the above it appears that the three repetitions would be three separate movements that have been combined into the one long trace...what to do with them individually is undoubtedly provided in the exercise instructions..
  1 Comment
William Rose
William Rose on 18 Mar 2025
@Heather, @dpb has explained how to extract the different segments of your data.
The data file includes simultaneous recordings of biceps and triceps EMGs at three time periods. For each recording, the moving RMS average was computed. (A window width of 25-40 msec is often used - see attached doc for details on why and how to do RMS filtering.) Therefore the data file includes four records for each of the three time periods: the RMS-filtered data and the original data. In your original plot, all twelve segments are plotted consecutively. The marked-up figure below shows how the data is arranged in your original plot. @dpb 's plot shows the four records for trial 1. You can adjust what he did, to make similar plots for trials 2 and 3.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!