From: happydude on
if i have a struct to hold attendance information at a school

and it looks like:

course.schedule
course.topic
course.attendance

there are 10 courses,
schedule is a list of dates, ordered sequentially with no gaps and correspond to a similarly ordered attendance numbers

how would i find the total attendance for each date in the union of the entire school schedule? using no for loops?
From: jrenfree on
On Nov 10, 1:05 pm, "happydude " <anonymou...(a)hotmail.com> wrote:
> if i have a struct to hold attendance information at a school
>
> and it looks like:
>
> course.schedule
> course.topic
> course.attendance
>
> there are 10 courses,
> schedule is a list of dates, ordered sequentially with no gaps and correspond to a similarly ordered attendance numbers
>
> how would i find the total attendance for each date in the union of the entire school schedule?  using no for loops?

Hmmm....I don't think this is the easiest way, but it works for me.

temp = [course.attendance];
temp2 = reshape(temp, length(course(1).attendance), length(course));
sum(temp2, 2)