embedded if statement not working
Show older comments
I have a large CSV file used for data collection. The sensor data is recorded as long as the power is on. When the test is initiated, the value of a cell changes to 3. I have created a simple embedded if statement that seems to be missing the values. Any help would be appreciated. Thanks
untitled = <5561x129> double %<---- Raw Data
a=1;
n=length(untitled);
for j=1:n
if untitled(n,54) ==3;
test_data(a,:)=untitled(n,:);
a=a+1;
end
end
but if I enter in the Command Window,
>> untitled(1680,54)
ans =
3
Thanks
Accepted Answer
More Answers (2)
Chris
on 3 Jan 2013
0 votes
Jan
on 3 Jan 2013
At first your code can be abbreviated:
index = (untitled(:, 54) == 3);
test_data = untitled(index, :);
Now it has not been explained, why you think that something is missing. Is test_data empty after the code ran?
Is the value exactly 3 or is it 2.999999999999999, which is displayed as 3 in the command window? Please test this:
untitled(1680,54) - 3
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!