From: Andrew Liu on
So this is what I have so far

for i=1:length(newtime)

if newtime(i,1) > 0 && newtime(i,1) <= (60*15)
value(i,1) = sum(ppt_data(1:i));

end

if newtime(i,1) > (60*15) && newtime(i,1) <= (60*30)
value1(i,1) = sum(ppt_data(1:i));

end

end

the thing is... I looked at the workspace and those files (value and value1) does not output what I wanted. It outputs a column of data with 0s and then when the statement is true it will add the values following the 0s. I was wondering how do i output to one file and not output the 0s and only the values?

Thank you
From: dpb on
Andrew Liu wrote:
> So this is what I have so far
>
> for i=1:length(newtime)
> if newtime(i,1) > 0 && newtime(i,1) <= (60*15)
> value(i,1) = sum(ppt_data(1:i));
> end
>
> if newtime(i,1) > (60*15) && newtime(i,1) <= (60*30)
> value1(i,1) = sum(ppt_data(1:i));
> end
> end
>
> the thing is... I looked at the workspace and those files (value and
> value1) does not output what I wanted. It outputs a column of data with
> 0s and then when the statement is true it will add the values following
> the 0s. I was wondering how do i output to one file and not output the
> 0s and only the values?

Again, there's no output in anything you're showing so how are we to
guess what you've done?

Show

a) the code the creates the problem,
b) what the problem (as you see it) is, and
c) what the desired result would be

All for a reasonably concise example, of course...

--
From: dpb on
dpb wrote:
> Andrew Liu wrote:
>> So this is what I have so far
>>
>> for i=1:length(newtime)
>> if newtime(i,1) > 0 && newtime(i,1) <= (60*15)
>> value(i,1) = sum(ppt_data(1:i));
>> end
>>
>> if newtime(i,1) > (60*15) && newtime(i,1) <= (60*30)
>> value1(i,1) = sum(ppt_data(1:i));
>> end
>> end
>>
>> the thing is... I looked at the workspace and those files (value and
>> value1) does not output what I wanted. It outputs a column of data
>> with 0s and then when the statement is true it will add the values
>> following the 0s. I was wondering how do i output to one file and not
>> output the 0s and only the values?
>
> Again, there's no output in anything you're showing so how are we to
> guess what you've done?

Oh...we have a failure to communicate, here...I guess you're call the
arrays value and value1 "files"...that's _most_ confusing nomenclature;
I was assuming you really meant a disk file.

I'd guess your problem now is that you haven't cleared the previously
created data in the arrays prior to rerunning. Add a

clear value*

before trying again and see if all doesn't improve.

It seems to me that what you've asked for though could be accomplished
w/ a pair of find() calls and cumsum() or even replacing the find() w/
logical addressing in the cumsum() argument reference to the data array.

--
From: Andrew Liu on
Thank you for your response! I'll give this a try!