% Sample file to demonstrate how to export data from Matlab to other
% applications

% A. Trani (October 5, 2013)

% This file generates a Matlab Binary file (.mat) called
% bridgesOfTheWorld.mat
% 
% File contains 4 variables with nridges of the World data (see line 36)

clear

% Import some data (bridges of the world file)

% Name  	Country  	Completed  	 Length (m) 
% Mackinac	United States	1957	8038 
% Xiasha	China	1991	8230 

% Read the complete Excel file (previous exercise)

[num,txt,raw] = xlsread('bridges_of_the_world_short.xls','Bridge data');

% Create individual variables with names: NOTE: convert cell array to
% string array (equal length)

noRows = length(raw);           % 23 entries for this case

bridgeName      = char(raw{2:noRows,1});         % converts cell array into a string array in Matlab - 
                                                                        % saves the result into variable bridgeName
bridgeCountry   = char(raw{2:noRows,2});        % saves result into string array bridgeCountry
bridgeYear         = num(:,1);                              % no need to convert - values are all numeric
bridgeLength     = num(:,2);                             % no need to convert - values are all numeric

% Save all 4 variables created in this script to a Matlab binary format

save bridgesOfTheWord   bridgeName bridgeCountry  bridgeYear  bridgeLength

