Matlab - checks on imported data


by bakes1
Tags: data analysis, matlab
bakes1
bakes1 is offline
#1
Dec9-09, 02:47 PM
P: 3
A bit of background~
I'm using a wii mote to collect accelerometer data, and have the data exported to an excel document.

This data is then imported into matlab using :
a = xlsread(fileName); %reads in file name
x = a(:, xColNum); %time
y1 = a(:, y1ColNum); %accel value x
y2 = a(:, y2ColNum); %accel value y
y3 = a(:, y3ColNum); %accel value z

what i'd like to do next is then set a threshold check so that if any of the values within each of the sets is greater than a decided value a trigger can be set.

I'm not sure how to run the initial check on the y1, y2 ,y3 values. My first thoughts are to run a for loop on the sets and then have if statements that execute when the given values are reached. My only problem is i'm not quite sure how to code this within the m file. Also should it be part of a seperate function of just below the above code.
Phys.Org News Partner Science news on Phys.org
SensaBubble: It's a bubble, but not as we know it (w/ video)
The hemihelix: Scientists discover a new shape using rubber bands (w/ video)
Microbes provide insights into evolution of human language
Mark44
Mark44 is offline
#2
Dec9-09, 03:14 PM
Mentor
P: 21,067
You could have three flag variables, one for each column, that are initialized to 0 and are set if you find a value that is above the threshold in a particular column. If you're interested only if any value in any of the three columns is above the threshold, you can probably get by with just one flag variable.

flag1 = 0
flag2 = 0
flag3 = 0
Threshold = 10000 % or whatever

for i=1:N
  if y1(i) >= Threshold
    flag1 = 1
  end
end


Register to reply

Related Discussions
Integrating data in Matlab Math & Science Software 0
Integrate data in MATLAB Programming & Computer Science 1
MATLAB Weighting Data Math & Science Software 0
How do I integrate a graph in matlab imported from simulink? Math & Science Software 0