removing saturday and sunday and the corresponding values from a table.

hi guys, I have a table which is in table format in matlab. the table has 5 million rows and 6 columns. here is a sample of the very first line:
'26.07.2004' '2:00' 0.637900000000000 0.638000000000000 0.637600000000000 0.637800000000000
Now this is not a cell array but a table and I want all the dates and their corresponding values in the rows to be removed that are Saturday or Sunday. Can anyone suggest something?
thank

 Accepted Answer

Look at this example
a={'25.10.2014' '2:00' 0.6379 0.6380 0.6376 0.6378
'26.10.2014' '2:00' 0.6379 0.6380 0.6376 0.6378
'27.10.2014' '2:00' 0.6379 0.6380 0.6376 0.6378}
b=cell2table(a)
idx=ismember(weekday(datenum(b.a1,'dd.mm.yyyy')),[2:6])
out=b(idx,:)

7 Comments

i get this error Error
using table/subsrefDot (line 76) Unrecognized variable name 'a1'.
Error in table/subsref (line 62) [varargout{1:nargout}] = subsrefDot(t,s);
Where is your code? and please adapt the code to your data!
The problem is that your cell array is horizontally arranged whilst mine is arranged vertically.I cannot change my cell array format as the file is large.is there another way.
a is the data in cell array format whereas x is the data in table format
a=table2cell(x)
>> idx=ismember(weekday(datenum(x.a1,'dd.mm.yyyy')),[2:6])
Error using table/subsrefDot (line 76)
Unrecognized variable name 'a1'.
Error in table/subsref (line 62)
[varargout{1:nargout}] = subsrefDot(t,s);
>> idx=ismember(weekday(datenum(x.a,'dd.mm.yyyy')),[2:6])
Error using table/subsrefDot (line 76)
Unrecognized variable name 'a'.
Error in table/subsref (line 62)
[varargout{1:nargout}] = subsrefDot(t,s);
this is a sample of my data:<</matlabcentral/answers/uploaded_files/20113/sample.png>>

Sign in to comment.

More Answers (0)

Asked:

AA
on 27 Oct 2014

Commented:

AA
on 29 Oct 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!