From 8b44229ef44f0558ce045e46ff833fb44df913c9 Mon Sep 17 00:00:00 2001 From: jofret Date: Mon, 21 Jun 2010 06:24:38 +0000 Subject: Tagging the 2.0 release of scilab2c --- macros/GeneralFunctions/Array2String.sci | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 macros/GeneralFunctions/Array2String.sci (limited to 'macros/GeneralFunctions/Array2String.sci') diff --git a/macros/GeneralFunctions/Array2String.sci b/macros/GeneralFunctions/Array2String.sci new file mode 100644 index 00000000..27e9aa15 --- /dev/null +++ b/macros/GeneralFunctions/Array2String.sci @@ -0,0 +1,40 @@ +function [StringArray] = Array2String(InArray); +// function [StringArray] = Array2String(InArray); +// ----------------------------------------------------------------- +// #RNU_RES_B +// Converts an input array into a string. Maximum 2D array are allowed. +// Ex.: InArray = [10, 4]; +// StringArray = "[10, 4]"; +// #RNU_RES_E +// +// Input data: +// InArray: Input array. +// +// Output data: +// StringArray: array converted into a string. +// +// Status: +// 13-May-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +[Nrows,Ncols] = size(InArray); + +StringArray = '['; +for counterrows = 1:Nrows + for countercols = 1:Ncols + StringArray = StringArray + string(InArray(counterrows,countercols)) + ','; + end + StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ',' + StringArray = StringArray+';'; +end +StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ';' +StringArray = StringArray+']'; +endfunction -- cgit