No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail
from MatPlanWDM v0.5 by Pablo Pavon MariƱo
Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

IO_writeTraffFile.m
% IO_writeTraffFile
% 
% Usage: IO_writeTraffFile(traff_trafficMatrix, fullpathname) 
%
% Abstract: This function writes a  Traffic File (*.traff) to the 
% filename selected by the user in the pathname selected by the user. A 
%  Traffic File (*.traff) contains the  Traffic Matrix, that
% is, the table of the  traffic demands for all the possible node
% pairs. 
%
% In the whole file the columns (fields) are separated by TABS and the rows
% by RETURNS. Each field column is represented  according to C language
% FORMAT. The FORMAT is a string containing C language conversion specifications. 
%A conversion specification controls the notation, alignment, significant digits, 
%field width, and other aspects of output format. The format string can 
%contain escape characters to represent nonprinting characters such as 
%newline characters and tabs. Conversion specifications begin with 
%the % character and contain these optional and required elements: 
% Flags (optional) 
% Width and precision fields (optional) 
% A subtype specifier (optional) 
% .Conversion character (required) 
%
% Arguments:
% o	In: 
%  traff_trafficMatrix(NxN): Average traffic flow offered between node pairs. The 
%   Traffic Matrix is a two-dimensional matrix with N (N: number of nodes) rows 
%   and N columns. An entry(s,d) means the average traffic flow from node 's' 
%   to node 'd', measured as the number of bits per second. 
%
% . fullpathname: String of the pathname of the Traffic File (*.traff)
%   to save, incluiding the filename: [pathname filename]
%
%
%                                       Ramon Aparicio Pardo,2007

function IO_writeTraffFile(traff_trafficMatrix, fullpathname) 

%We check input arguments
if (nargin==0),  help IO_writeTraffFile;return, end %help calling
if (nargin~=2),  error('1: Incorrect number of arguments.'),end %Number of input arguments different of 2
if(size(traff_trafficMatrix,1) ~= size(traff_trafficMatrix,2)), error('2: Argument "traff_trafficMatrix" must be a square matrix'), end
if(isa(traff_trafficMatrix, 'numeric')~=1), error('3: Argument "traff_trafficMatrix" must be an integer or floating-point array'), end


%We open the file to save our 'Traffic File (*.traff)'
% [filename, pathname] = uiputfile({'*.traff','Traffic File (*.traff)'},'Save Traffic File as','Data\Traffics\');
% fullpathname=[pathname filename];
fid = fopen(fullpathname, 'w');

%We write the traffic string from the traff_trafficMatrix
[traffString] = IO_writeTraffString(traff_trafficMatrix) ;

%We write the string in the file
fprintf(fid,traffString);
fclose(fid);

Contact us