Thursday, September 18, 2008

Mathworks File Exchange Profile Information - Part 2

Ok, A quick little update here before I head off on holidays!

Continuing on from my previous post I realised that I wanted to watch how my submissions were performing over time (my memory is not quite what it used to be).

I had a crazy idea, could I create a Timer that would scrape my user statistics from the Mathworks File Exchange site and save them in a format such that I could plot them easily???

Introducing Monitor File Exchange Statistics.

Plotting my stats for the past week:
I'm not a big fan of the look of the submitted files plot as it can get a bit busy. I'm envisaging a lightweight GUI with a drop-down selector for each submitted file might be nicer. Particularly for those people with a large number of submitted files. I'll update the submission after I get back to do something like this.

To set the automatic scraping of your File Exchange statistics you need to do the following:
  1. Download the required MATLAB files from here. Need Monitor File Exchange Stats and Retrieve File Exchange Profile Information.
  2. Place the files somewhere in your MATLAB path. Note, if you already have a startup.m, just add the InitialiseFileExchangeInfoTimer and UpdateFileExchangeInfoTimerFcn to your existing startup.m and call InitialiseFileExchangeInfoTimer from within.
  3. Modify FEX_AUTHOR_ID and UPDATE_PERIOD with your File Exchange Author ID and your desired scrape frequency (seconds). The cache file defaults to being stored in your MATLAB root directory, modify FEX_SAVE_FILE if you wish to customise this location.
  4. Save any changes and restart MATLAB.
  5. Each time you restart Matlab you will be presented with a plot of your current and historical stats (for as long as you have been scraping).
  6. To manually plot your current stats, call plotLocalFileExchangeInfo(cache_file)
In terms of file size, I've had the script running every 10 minutes for nearly a week and my cache file is only 45 kB.

Thursday, September 4, 2008

Mathworks File Exchange Profile Information - Part 1

I have been uploading files to the Mathworks File Exchange and have found that I get a sick pleasure looking at my profile page each morning and seeing what people are downloading.

So I thought I would write some MATLAB that would streamline my morning operation as well as gather some additional stats such as downloads/rank over time.

Part 1 - Retrieving File Exchange Profile Information

I've developed a simple function that will, given an Author ID download the Author's profile page from the Mathworks File Exchange and parse it for the Name, Total Downloads, Rank and the list of submitted files.

The function is available on the Mathworks File Exchange: Retrieve File Exchange Profile Information
function file_exchange_info = getFileExchangeProfileInfo(author_id)
%GETFILEEXCHANGEPROFILEINFO Retrieve File Exchange information
% file_exchange_info = GETFILEEXCHANGEPROFILEINFO(author_id) retrieves an
% Author's information from the Mathworks File Exchange
% (
% file_exchange_info is a structure with the following fields:
% .author_id - As supplied to the function
% .author_name - Author name
% .rank - Author rank
% .num_downloads - Total number of downloads
% .submitted_files - An array of structures with the following fields:
% .id - File Exchange submission ID
% .num_downloads - Number of downloads for this submission
% .name - Number of reviews for this file
% If the File Exchange page could not be loaded, file_exchange_info will be
% returned empty.
% Examples:
% file_exchange_info = getFileExchangeProfileInfo(1109866) % My profile
% See also urlread

To use the script simply call it supplying the author if interest's Author ID. For example lets have a look at Stuart McGarrity's profile page with Author ID 126174 (currently the number 1 ranked author):
>> info = getFileExchangeProfileInfo(126174)
info =
author_id: 126174
author_name: 'Stuart McGarrity'
rank: 1
num_downloads: 163181
submitted_files: [1x23 struct]
Looking at each submitted file in particular:
>> for i = 1:length(info.submitted_files)

ans =
id: 2262
name: '802.11b PHY Simulink Model'
num_downloads: 21054
ans =
id: 722
name: 'Bluetooth modulation and frequency hopping'
num_downloads: 19999
ans =
id: 724
name: 'DTMF generator and receiver'
num_downloads: 15117
ans =
id: 907
name: 'Bluetooth voice transmission'
num_downloads: 12225
ans =
id: 3213
name: '802.11b PHY MATLAB Code'
num_downloads: 11803
ans =
id: 2283
name: 'Bluetooth Full Duplex Voice and Data Transmission'
num_downloads: 10830
ans =
id: 746
name: 'IS-95A CDMA Power Control'
num_downloads: 10406
ans =
id: 787
name: 'IS-95A Mobile Phone Call Processing'
num_downloads: 9214
ans =
id: 4380
name: 'MATLAB for C/C++ Programmers'
num_downloads: 9174
ans =
id: 9060
name: 'Handling Large Data Sets Efficiently in MATLAB'
num_downloads: 8329
ans =
id: 7595
name: [1x59 char]
num_downloads: 8165
ans =
id: 2596
name: '10Base-T Ethernet'
num_downloads: 5366
ans =
id: 1550
name: 'Packet Switch'
num_downloads: 4564
ans =
id: 9622
name: 'MDF Import Tool and Function'
num_downloads: 3491
ans =
id: 3939
name: 'Import Fig File to Axes'
num_downloads: 2386
ans =
id: 6528
name: 'Introduction to MATLAB 7 Webinar Demonstrations'
num_downloads: 2168
ans =
id: 13548
name: 'chkmem'
num_downloads: 1941
ans =
id: 18972
name: [1x78 char]
num_downloads: 1941
ans =
id: 16075
name: 'Textscantool'
num_downloads: 1511
ans =
id: 18971
name: [1x70 char]
num_downloads: 1410
ans =
id: 14438
name: [1x69 char]
num_downloads: 924
ans =
id: 9298
name: 'Data and M-Files for Demonstrations on MATLAB Demo Page'
num_downloads: 663
ans =
id: 19540
name: [1x77 char]
num_downloads: 614

Part 2 of this post will detail how I will be using the information returned by this function over time.

Now all I need to do is write it!