summaryrefslogtreecommitdiff
path: root/2.3-1/macros/GeneralFunctions/Array2String.sci
diff options
context:
space:
mode:
authorAnkit Raj2017-06-21 10:26:59 +0530
committerAnkit Raj2017-06-21 10:26:59 +0530
commita555820564d9f2e95ca8c97871339d3a5a2081c3 (patch)
treeadb074b66a8e6750209880e6932305ce0a94c8bf /2.3-1/macros/GeneralFunctions/Array2String.sci
downloadScilab2C-a555820564d9f2e95ca8c97871339d3a5a2081c3.tar.gz
Scilab2C-a555820564d9f2e95ca8c97871339d3a5a2081c3.tar.bz2
Scilab2C-a555820564d9f2e95ca8c97871339d3a5a2081c3.zip
Updated Scilab2C
Diffstat (limited to '2.3-1/macros/GeneralFunctions/Array2String.sci')
-rw-r--r--2.3-1/macros/GeneralFunctions/Array2String.sci40
1 files changed, 40 insertions, 0 deletions
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