From b43eccd4cffed5bd1017c5821524fb6e49202f78 Mon Sep 17 00:00:00 2001 From: Sandeep Gupta Date: Sun, 18 Jun 2017 23:55:40 +0530 Subject: First commit --- 2.3-1/macros/GeneralFunctions/Array2String.sci | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 2.3-1/macros/GeneralFunctions/Array2String.sci (limited to '2.3-1/macros/GeneralFunctions/Array2String.sci') diff --git a/2.3-1/macros/GeneralFunctions/Array2String.sci b/2.3-1/macros/GeneralFunctions/Array2String.sci new file mode 100644 index 00000000..27e9aa15 --- /dev/null +++ b/2.3-1/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