classify data from csv fil
显示 更早的评论
hello everyone
I want to read data from csv file and classify these data. my csv look like this:
0
0.139999945
0.209999918
12.86283386
0
-0.649996554
-2.609774285
-114.4151
...
its [154*1][row*col], I want to classify these data as
- (if data = 0 then write 0 in the second column)
- (if 0<data<=45 then print 1)
- (if 45<data<=90 then print 2)
- (if 0>data>=-45 then print 3)
- (if -45>data>=-90 then print 4)
I don't know what should I write in the condition statement! the following is my attempt but it doesn't give the desired output.
M = csvread('imu.csv')
[rows cols] = size(M);
for k = 1:length(M)
if M == 0
A=0;
elseif 0<M<=45
A=1;
elseif 45<M<=90
A=2;
elseif 0>M>=-45
A=3;
else
A=4;
end
end
csvwrite('imu2.csv',A);
1 个评论
Image Analyst
2018-5-11
编辑:Image Analyst
2018-5-11
"write 0 in the second column" of what , A or M? If A, then what is in the first column of A?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!