f

reading data from excel and summing it up

```Hello. I'm having problems figuring out how to do this script:

I have an excel file containing: Dates, Time, Value

When I tried to read the excel file through Matlab, it changes the my 24hour time to decimal value. How do I keep it as 24 hour time values?

I need to somehow match the date and sum up values within every 15 minutes

Example:

12	10	9	13:01:00		0.01
12	10	9	22:36:52		0.01
12	10	9	22:40:27		0.01
12	10	9	22:42:41		0.01
12	10	9	22:45:37		0.01
12	10	9	22:47:25		0.01
12	10	9	22:51:12		0.01
12	10	9	22:54:25		0.01
12	10	9	22:58:04		0.01
12	10	9	23:01:38		0.01

So can anyone help me create a code to sum the 0.01 values for every 15 minutes and then combine the date that falls within the same time intervals?

Thank you
```
 0
Andrew
7/6/2010 2:07:04 AM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader.

5 Replies
698 Views

Similar Articles

[PageSpeed] 25

```On Jul 6, 2:07=A0pm, "Andrew Liu" <nos...@gmail.com> wrote:
> Hello. I'm having problems figuring out how to do this script:
>
> I have an excel file containing: Dates, Time, Value
>
> When I tried to read the excel file through Matlab, it changes the my 24h=
our time to decimal value. How do I keep it as 24 hour time values?
>
> I need to somehow match the date and sum up values within every 15 minute=
s
>
> Example:
>
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 13:01:00 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:36:52 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:40:27 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:42:41 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:45:37 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:47:25 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:51:12 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:54:25 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 22:58:04 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
> 12 =A0 =A0 =A010 =A0 =A0 =A09 =A0 =A0 =A0 23:01:38 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A00.01
>
> So can anyone help me create a code to sum the 0.01 values for every 15 m=
inutes and then combine the date that falls within the same time intervals?
>
> Thank you

How is this post different from your post 3 days ago:
99ef0b02c4c157/d592d48b00246d8a#d592d48b00246d8a

And have you tried the suggestions given you back then?

```
 0
mulgor (3007)
7/6/2010 2:38:08 AM
```Hello

Thanks for responding. I couldn't figure it out before. I'm not quite sure how to go at it. So far I've only read the data. I'm not sure if I should read all the data first? Or one at a time (date, time, value)

I'm having trouble getting started. I was thinking of doing a "for loop" and "if statements".

I took a class before, about a year ago, but I totally forgot how to write codes

-----------
clear all;
clc;

for i=1:4097 %number of rows

end

------------

so far I only got that. so I need to read 4097 data. I just don't know where to start. i'm in desperate need of assistance.

```
 0
Andrew
7/6/2010 3:05:04 AM
```help anyone?
```
 0
Andrew
7/6/2010 3:42:22 PM
```On Jul 7, 3:42=A0am, "Andrew Liu" <nos...@gmail.com> wrote:
> help anyone?

Instead of sitting there waiting for others to solve YOUR problem, you
should be trying to solve it yourself.
It's pretty basic problem solving.  It's not rocket science.

What did you get when you executed those two xlsread commands?
Do value and time have any data in them?
If not, you need to read the help xlsread again and see what you have
missed out.
If they are not empty, what do the first few data look like?
Are they sensible?
If not, go back and read help xlsread again and see what you are doing
wrong.
```
 0
TideMan
7/6/2010 7:58:54 PM
```I'm not asking for anyone to solve my problem. I'm asking someone who can give me guidance and help. So far no one has provided any...

anyways,

this is my code

-----

clear all;
clc;

% input data

% the output file
fid = fopen('dataout.txt','w');

%assign data
date = as(:,1:3);
ppt_data = as(:,end);
time = as(:,4:6);
k = 0;

for i=1:length(time)
if time(i,1:3) < [13 15 0]
for ii = 1
k = k+1;
sum(k,:) = sum(ppt_data(ii,:));
end
elseif time(i,1:3) > [22 16 0] & time(1,i:3) < [22 60 0]
for ii = 1
k = k+1;
sum(k,:) = sum(ppt_data(ii,:));
end
end
end
------

So I have a list of time data which consists of 3 columns (each column corresponds to the hour, minutes, seconds, respectively). I'm trying to experiment with this data seeing if I can add values together that corresponds to the times (within 15 minutes of each other).

Also, with the times, I have dates, that corresponds to the times. The times are set in 24 hours time frame.
```
 0
Andrew
7/6/2010 8:13:06 PM