Index in position 2 exceeds array bounds (must not exceed 2)

The assignment;;;
Section 3: Write a command to load data_set2.txt, and define time as column 1, and EMG data for muscle X as column 2, muscle Y as column 3 and muscle Z as column 4. Create the following variables:
o rate that defines the rate of capture (2000 Hz)
o timeinterval computed based on the rate of capture per second
o num as the length of samples collected
o totaltime as a function of num and timeinterval variables
o time starting at timeinterval and using timeinterval as the fixed interval between
samples to totaltime
Can someone help me out and indicate what I did was wrong...

7 Commenti

Hard to tell without the full text of the error message or the input file. I suspect that your data_set2.txt file has only two columns (or at least only two columns have been imported into matlab) so of course, trying to access the 3rd column doesn't work.
Ok that makes sense....
the assignment said i need to create four columns so how do i do that if the file has only two columns?
the professors sent me this--
This is good, but you have to understand what you are doing in these few lines:
MuscleX = data_set2(:,2); %put Muscle X data into array
MuscleY = data_set2(:,3); %put Muscle Y data into array
MuscleZ = data_set2(:,4); %put Muscle Z data into array
You determined which variable was which column. Muscle X Y and Z
Then you try to do the following:
rate = 2000;
timeinterval = 1/rate;
num = length (EMG);
Not sure what was i suppose to do in these few lines?
What does this show:
whos data_set2
"the assignment said i need to create four columns so how do i do that if the file has only two columns"
As I said, "hard to say without seeing the input file". Since you can't magic data out of thin air, I'd say get a file with 4 columns.
I got this error
Error using abs
Too many input arguments.
Error in ArpAssignment3 (line 95)
RecifiedEMG1 = abs(HighPassFilterEMG1,2);
Do you know why I did wrong?
As the error tells you, you passed too many inputs to abs. abs only works with one input. I've no idea what the 2 in your call is meant to do.

Accedi per commentare.

Risposte (0)

Tag

Richiesto:

il 1 Mar 2020

Commentato:

il 6 Mar 2020

Community Treasure Hunt

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

Start Hunting!

Translated by