MATLAB Answers

How to repeat a calculation in all rows

11 views (last 30 days)
Marc Elmeua
Marc Elmeua on 30 Nov 2018
Answered: madhan ravi on 4 Dec 2018
Hi there,
I have a sample of muscle contractions from 12 different muscles for 10 subjects. All time normalized (100AU). I want to apply the following calculation to each one of them without having to copy paste the code:
Max = max(muscle); %muscle has to be specified by hand
threshold = 0.25*Max;
indices = find(abs(muscle)>2);
muscle(indices) = NaN;
So basically I am finding the maxEMG activity of the contraction, taking 25% as a cuttoff threshold and eliminating any value below that threshold. And I would like that to be repeated for each muscle, but I can't figure out how to use a loop whithout the name of the muscle being the same over and over.
Any ideas?
Thanks in advance!

  6 Comments

Show 3 older comments
Greg
Greg on 2 Dec 2018
Also, the find is unnecessary in this situation. Logical indexing is much better.
madhan ravi
madhan ravi on 4 Dec 2018
comment moved to answer section

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 4 Dec 2018
max(muscles,[],2)

  0 Comments

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 2 Dec 2018
I'm guessing that the 10 subjects data is in 10 different data files. You need to read in each one, and process it, which might mean processing each of the 12 signals for that subject. So you need to loop over all files like is explained in the FAQ: Click Here

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!