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

% A. Trani (October 5, 2013)

% This file generates an ASCII file containing numerical data for bridge
% length and bridge year of completion. Samples hsown using tab and comma
% delimited formats (see lines 35 and 37)

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

bridgeYear         = num(:,1);                             % no need to convert - values are all numeric
bridgeLength     = num(:,2);                             % no need to convert - values are all numeric

% collectAllVariables = [bridgeName, bridgeCountry,  bridgeYear,  bridgeLength];

% Create a text file (called myOutout2.txt) and write the numerical data
% variables (year completed and length) to an ASCII file

dlmwrite('myOutput2.txt',[bridgeYear bridgeLength],'delimiter',',')

% dlmwrite('myOutput2.txt',[bridgeYear bridgeLength],'delimiter','\t')
