Matlab - checks on imported data

  • Context: MATLAB 
  • Thread starter Thread starter bakes1
  • Start date Start date
  • Tags Tags
    Data Matlab
Click For Summary
SUMMARY

This discussion focuses on importing accelerometer data from an Excel document into MATLAB using the xlsread function. The user aims to implement a threshold check on the imported data values for three axes (x, y, z) to trigger flags when values exceed a specified threshold. The proposed solution involves using a for loop combined with if statements to evaluate each data point against the threshold, with flag variables initialized to indicate whether any values exceed the threshold. The user seeks guidance on the implementation details within the MATLAB script.

PREREQUISITES
  • Familiarity with MATLAB programming, specifically using xlsread
  • Understanding of basic control structures in MATLAB, including for loops and if statements
  • Knowledge of data types and indexing in MATLAB arrays
  • Experience with threshold-based data analysis techniques
NEXT STEPS
  • Explore MATLAB's xlsread function documentation for advanced usage
  • Learn about MATLAB array indexing and manipulation techniques
  • Investigate creating custom functions in MATLAB for modular code
  • Research best practices for implementing threshold checks in data analysis
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and engineers working with sensor data who need to implement threshold checks and data validation techniques in their projects.

bakes1
Messages
3
Reaction score
0
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 separate function of just below the above code.
 
Physics news on Phys.org
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.

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

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

Similar threads

Replies
1
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K