From: Nash Dima on
Dear all,
Im trying to manipulate some data that I have in an Excel file and perform some basic calculations.

My data is in three colums. The first two colums are consisted of strings ( names, places) and the third is numbers ( time spent in those places in minutes).The spreadsheet looks like this:
Name Place Time
John Park 100
John Park 10
Helen Shop 45
John Park 45
John Garden 56
John Shop 78
Mike Home 457
Peter Shop 45
Mike Office 78
Mike Garden 45
Helen Garden 725
Mary Park 78
John Park 45
.... ..... ....
So the names are repeated as well as the places that they have been. Essentialy I need to make a GUI where I ll be able to choose one name from a drop down list and a place and get the average of the time that this person spent at that place. (sum of time spent at a place / Times the person s been there)

Hopefully, the GUI shouldnt be a problem but Im not sure how to tackle this. Is there an equivalent of a VLOOKUP function as in excel. Is there a similar example I could look into?
Really need to do this so any input would be very appreciated.
Thanks
Nas
From: us on
"Nash Dima" <sfigga00(a)hotmail.com> wrote in message <hrsa0r$g40$1(a)fred.mathworks.com>...
> Dear all,
> Im trying to manipulate some data that I have in an Excel file and perform some basic calculations.
>
> My data is in three colums. The first two colums are consisted of strings ( names, places) and the third is numbers ( time spent in those places in minutes).The spreadsheet looks like this:
> Name Place Time
> John Park 100
> John Park 10
> Helen Shop 45
> John Park 45
> John Garden 56
> John Shop 78
> Mike Home 457
> Peter Shop 45
> Mike Office 78
> Mike Garden 45
> Helen Garden 725
> Mary Park 78
> John Park 45
> ... ..... ....
> So the names are repeated as well as the places that they have been. Essentialy I need to make a GUI where I ll be able to choose one name from a drop down list and a place and get the average of the time that this person spent at that place. (sum of time spent at a place / Times the person s been there)
>
> Hopefully, the GUI shouldnt be a problem but Im not sure how to tackle this. Is there an equivalent of a VLOOKUP function as in excel. Is there a similar example I could look into?
> Really need to do this so any input would be very appreciated.
> Thanks
> Nas

a hint:
- jd's CONSOLIDATOR, which is available from the FEX, will be helpful...

http://www.mathworks.com/matlabcentral/fileexchange/8354

% other pointers include basic stuff like
help unique;
help histc;

us
From: ade77 on
"Nash Dima" <sfigga00(a)hotmail.com> wrote in message <hrsa0r$g40$1(a)fred.mathworks.com>...
> Dear all,
> Im trying to manipulate some data that I have in an Excel file and perform some basic calculations.
>
> My data is in three colums. The first two colums are consisted of strings ( names, places) and the third is numbers ( time spent in those places in minutes).The spreadsheet looks like this:
> Name Place Time
> John Park 100
> John Park 10
> Helen Shop 45
> John Park 45
> John Garden 56
> John Shop 78
> Mike Home 457
> Peter Shop 45
> Mike Office 78
> Mike Garden 45
> Helen Garden 725
> Mary Park 78
> John Park 45
> ... ..... ....
> So the names are repeated as well as the places that they have been. Essentialy I need to make a GUI where I ll be able to choose one name from a drop down list and a place and get the average of the time that this person spent at that place. (sum of time spent at a place / Times the person s been there)
>
> Hopefully, the GUI shouldnt be a problem but Im not sure how to tackle this. Is there an equivalent of a VLOOKUP function as in excel. Is there a similar example I could look into?
> Really need to do this so any input would be very appreciated.
> Thanks
> Nas


This is just my opinion--

I do not understand why you must use MATLAB to solve this excel problem. Every software has its strengths and weaknesses. While MATLAB can do this job, Excel is more appropriate to solve it, or better still MS Access.

If you are using Excel, you can easily use a pivot table to solve your problem, for better flexibility, you can import it to MS Access, and solve it easily.

If you want a GUI, you can easily create that in Excel using Visual Basic, or in MS Access, you have many options to build your GUI.

However, you can still use MATLAB, I am not a big fan of MATLAB GUI - which in my opinion is something the mathworks should improve upon.

In my final opinion to you, you should use excel to solve this problem. If the calculations you want to do are complex, that Excel can not handle, or you just insist you want to use MATLAB, then check out the following help in MATLAB:
xlsread
xlswrite
importdata
accumarray
string
MATLAB GUIDE
activex
MATLAB file exchange
cell array
structure
etc
From: Nash Dima on

> a hint:
> - jd's CONSOLIDATOR, which is available from the FEX, will be helpful...
>
> http://www.mathworks.com/matlabcentral/fileexchange/8354
>
> % other pointers include basic stuff like
> help unique;
> help histc;
>
> us

Thanks for your answers. This is a small part of project that has be going on for few years and great part of the analysis has already be done in matlab so Excel or Access wouldnt be an option as the deliverables have been pre agreed from my predecessors. The variables in the example actually represent operational times of equipment, sites and circuits and come in thousands.
So I need to stick with Matlab. The good thing is that time is in our side ( not that much) as well as the will to understand and learn.

The consolidator seems to be exactly what I need. It kind of works for some sets of data but when for example
x = Name
y=Time
in [xcon,ycon,ind] = consolidator(x,y,aggregation_mode,tol)
I get an error: Function 'diff' is not supported for class 'cell'.
Does this fuction apply to strings? (Im sure it does, you wouldn suggest it otherwise)
Im doing my homework with data structures but I would appreciate any suggestions / guidance.
Thanks,
Nas