embedded if statement not working
显示 更早的评论
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
采纳的回答
更多回答(2 个)
Jan
2013-1-3
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
类别
在 帮助中心 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!