From: Luca Bergamasco on
Hi all,

I'm dealing with a geographical analysis over a large territory. I have an excel spreadsheet which contains all the buildings (in a column), the municipality they belong to (other column), other informations in other columns like roof surface area of each building etc..

What I would like to do is to sum the roof surface area of the buildings by municipality. I'm thinking about some logical correlation to "group" elements belonging to the same municipality (same code), but I can't figure out how to do that.

Any idea would be really appreciated! Thanks in advance!
From: us on
"Luca Bergamasco" <luca_bergamasco(a)hotmail.com> wrote in message <huafpo$1qo$1(a)fred.mathworks.com>...
> Hi all,
>
> I'm dealing with a geographical analysis over a large territory. I have an excel spreadsheet which contains all the buildings (in a column), the municipality they belong to (other column), other informations in other columns like roof surface area of each building etc..
>
> What I would like to do is to sum the roof surface area of the buildings by municipality. I'm thinking about some logical correlation to "group" elements belonging to the same municipality (same code), but I can't figure out how to do that.
>
> Any idea would be really appreciated! Thanks in advance!

there are many solutions to this evergreen...
show CSSM a typical yet small(!) set of your data and the form it's represented in ML...

us
From: Clint_E on
"us " <us(a)neurol.unizh.ch> wrote in message <huahcs$fq6$1(a)fred.mathworks.com>...
> "Luca Bergamasco" <luca_bergamasco(a)hotmail.com> wrote in message <huafpo$1qo$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > I'm dealing with a geographical analysis over a large territory. I have an excel spreadsheet which contains all the buildings (in a column), the municipality they belong to (other column), other informations in other columns like roof surface area of each building etc..
> >
> > What I would like to do is to sum the roof surface area of the buildings by municipality. I'm thinking about some logical correlation to "group" elements belonging to the same municipality (same code), but I can't figure out how to do that.
> >
> > Any idea would be really appreciated! Thanks in advance!
>
> there are many solutions to this evergreen...
> show CSSM a typical yet small(!) set of your data and the form it's represented in ML...
>
> us

Thanks,

I've read the xls with xlsread (actually the original format is dbf, from GIS). Here an example of the data:

y =

1.0e+003 *

0.3731 0.0260
0.3394 0.0250
2.3127 0.0250
0.7281 0.0250
0.3856 0.0260
2.5479 0.0260
1.9064 0.0260
1.1297 0.0300
1.3849 0.0300
0.3811 0.0300
0.3167 0.0260
2.2314 0.0210
1.6781 0.0210
0.3487 0.0210
2.1617 0.0210
0.0322 0.0260
0.0370 0.0260

I want to sum the elements of the first column according to the second, that is, summing the rows of the first column which has the same code in the second.

Thanks!
From: Oleg Komarov on
"Clint_E " <luca_bergamasco(a)hotmail.com> wrote in message <huak4c$ecb$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <huahcs$fq6$1(a)fred.mathworks.com>...
> > "Luca Bergamasco" <luca_bergamasco(a)hotmail.com> wrote in message <huafpo$1qo$1(a)fred.mathworks.com>...
> > > Hi all,
> > >
> > > I'm dealing with a geographical analysis over a large territory. I have an excel spreadsheet which contains all the buildings (in a column), the municipality they belong to (other column), other informations in other columns like roof surface area of each building etc..
> > >
> > > What I would like to do is to sum the roof surface area of the buildings by municipality. I'm thinking about some logical correlation to "group" elements belonging to the same municipality (same code), but I can't figure out how to do that.
> > >
> > > Any idea would be really appreciated! Thanks in advance!
> >
> > there are many solutions to this evergreen...
> > show CSSM a typical yet small(!) set of your data and the form it's represented in ML...
> >
> > us
>
> Thanks,
>
> I've read the xls with xlsread (actually the original format is dbf, from GIS). Here an example of the data:
>
> y =
>
> 1.0e+003 *
>
> 0.3731 0.0260
> 0.3394 0.0250
> 2.3127 0.0250
> 0.7281 0.0250
> 0.3856 0.0260
> 2.5479 0.0260
> 1.9064 0.0260
> 1.1297 0.0300
> 1.3849 0.0300
> 0.3811 0.0300
> 0.3167 0.0260
> 2.2314 0.0210
> 1.6781 0.0210
> 0.3487 0.0210
> 2.1617 0.0210
> 0.0322 0.0260
> 0.0370 0.0260
>
> I want to sum the elements of the first column according to the second, that is, summing the rows of the first column which has the same code in the second.
>
> Thanks!

Pivot( [y(:,2), ones(size(y,1),1), y(:,1)])
ans =
NaN 0.021 0.025 0.026 0.03
1 6.4199 3.3802 5.5989 2.8957

You can find Pivot here: http://www.mathworks.com/matlabcentral/fileexchange/26119-pivotunpivot

Oleg
From: Clint_E on
"us " <us(a)neurol.unizh.ch> wrote in message <huahcs$fq6$1(a)fred.mathworks.com>...
> "Luca Bergamasco" <luca_bergamasco(a)hotmail.com> wrote in message <huafpo$1qo$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > I'm dealing with a geographical analysis over a large territory. I have an excel spreadsheet which contains all the buildings (in a column), the municipality they belong to (other column), other informations in other columns like roof surface area of each building etc..
> >
> > What I would like to do is to sum the roof surface area of the buildings by municipality. I'm thinking about some logical correlation to "group" elements belonging to the same municipality (same code), but I can't figure out how to do that.
> >
> > Any idea would be really appreciated! Thanks in advance!
>
> there are many solutions to this evergreen...
> show CSSM a typical yet small(!) set of your data and the form it's represented in ML...
>
> us

Thanks,

I've read the xls with xlsread (actually the original format is dbf, from GIS). Here an example of the data:

y =

1.0e+003 *

0.3731 0.0260
0.3394 0.0250
2.3127 0.0250
0.7281 0.0250
0.3856 0.0260
2.5479 0.0260
1.9064 0.0260
1.1297 0.0300
1.3849 0.0300
0.3811 0.0300
0.3167 0.0260
2.2314 0.0210
1.6781 0.0210
0.3487 0.0210
2.1617 0.0210
0.0322 0.0260
0.0370 0.0260

I want to sum the elements of the first column according to the second, that is, summing the rows of the first column which has the same code in the second.

Thanks!