Update cellstr, num2cell and cell2mat (+ help pages). 98/17098/3
Charlotte HECQUET [Mon, 24 Aug 2015 12:08:10 +0000 (14:08 +0200)]
Change-Id: I08d3e1ad879ca707aa87aa2b6c9211c5dbd70dd8

scilab/modules/elementary_functions/help/en_US/num2cell.xml
scilab/modules/elementary_functions/help/ja_JP/num2cell.xml
scilab/modules/elementary_functions/macros/cell2mat.sci
scilab/modules/elementary_functions/macros/cellstr.sci
scilab/modules/elementary_functions/macros/num2cell.sci

index 4e28747..971e2e3 100644 (file)
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"> 
-            A=[1 2; 3 4]
+        <programlisting role="example">
+            A = [1 2; 3 4]
             num2cell(A)
             M = hypermat([2 3 2 2],1:24)
-            c=num2cell(M,[1 2])
+            c = num2cell(M,[1 2])
             size(c)
-            size(c(1).entries)
-            
-            A=["a", "b"; "c" "d"]
+            size(c{1})
+
+            A = ["a", "b"; "c" "d"]
             num2cell(A)
         </programlisting>
     </refsection>
index 2af0927..6aa3972 100644 (file)
         <title>δΎ‹</title>
         
         <programlisting role="example"> 
-            
-            A=[1 2; 3 4]
-            
+            A = [1 2; 3 4]
             num2cell(A)
-            
             M = hypermat([2 3 2 2],1:24)
-            
-            c=num2cell(M,[1 2])
-            
+            c = num2cell(M,[1 2])
             size(c)
+            size(c{1})
             
-            size(c(1).entries)
-            
-            A=["a", "b"; "c" "d"]
-            
+            A = ["a", "b"; "c" "d"]
             num2cell(A)
-            
         </programlisting>
         
     </refsection>
index 257a9da..f502f1f 100644 (file)
@@ -28,18 +28,18 @@ function y= cell2mat(c)
         if typeof(c) <> "ce" then //input argument must be a cell
             error(msprintf(gettext("%s: Wrong type for input argument #%d: Cell expected.\n"),"cell2mat",1));
         end
-        cecomptype=typeof(c(1).entries) //cecomptype is the type of the first component of the cell
+        cecomptype=typeof(c{1}) //cecomptype is the type of the first component of the cell
         for i=1:prod(size(c))
-            if typeof(c(i).entries) <> cecomptype then //all components of input cell must have the same type
+            if typeof(c{i}) <> cecomptype then //all components of input cell must have the same type
                 error(msprintf(gettext("%s: Wrong type for input argument #%d: Same type expected for all cell contents"),"cell2mat",1));
             end
         end
         if  0 < size(size(c),"*") & size(size(c),"*") <= 2 then //size of cell is least or equal to 2
             ytemp=list(1:size(c,1));
             for i=1:size(c,1)
-                ytemp(i)=c(i,1).entries;
+                ytemp(i)=c{i,1};
                 for j=2:size(c,2)
-                    ytemp(i)=[ytemp(i) c(i,j).entries];
+                    ytemp(i)=[ytemp(i) c{i,j}];
                 end
                 if i==1 then
                     y=ytemp(i);
@@ -60,9 +60,9 @@ function y= cell2mat(c)
             for l=1:csizeprod/(size(c,1)*size(c,2))
                 ylist=list(1:size(c,1))
                 for i=1:size(c,1)
-                    ylist(i)=c(i,1,l).entries;
+                    ylist(i)=c{i,1,l};
                     for j=2:size(c,2)
-                        ylist(i)=[ylist(i) c(i,j,l).entries];
+                        ylist(i)=[ylist(i) c{i,j,l}];
                     end
                     if i==1 then
                         ytemp(l)=ylist(i);
index 6fc9b29..f47acdf 100644 (file)
@@ -31,10 +31,10 @@ function   c=cellstr(s)
         error(msprintf(gettext("%s: Wrong type for input argument #%d: Matrix of string expected.\n"),"cellstr",1));
     end
 
-    C=cell(size(s,1),1);
+    c=cell(size(s,1),1);
 
     for i=1:size(s,1)
-        c(i,1).entries=strcat(s(i,:));
+        c{i,1} = strcat(s(i,:));
     end
 
 endfunction
index b3297c1..7c898d4 100644 (file)
@@ -12,7 +12,7 @@ function  y=num2cell(x,dimens)
     // NUM2CELL function converts an array of double or string or boolean into a cell array
     // if there is just one input argument x, then it returns a cell which has the same size and the same components than x.
     // if there are two input arguments x and dimens, y is obtained after reduction to 1 of the x dimensions sizes contained in the vector dimens.
-    // The dimensions sizes of components of y (i.e y(i).entries) are equal to the dimensions sizes of x whose the numbers are in dimens vector
+    // The dimensions sizes of components of y (i.e y{i}) are equal to the dimensions sizes of x whose the numbers are in dimens vector
     // if size(x)=[2 3 4 5 6] and dimens=[2 4] -> size(y)=[2 1 4 1 6] , the sizes of the second (=dimens(1)) and the fourth (=dimens(2)) dimensions of x are reduced to 1 to obtain y. And size(y(i))=[1,3,1,5,1], the sizes of the second (=dimens(1)) and the fourth (=dimens(2)) dimensions of y(i) are equal to the sizes of the second and the fourth dimensions of x (i.e 3 and 5), the others dimensions are equal to 1
     //
     // Output
@@ -33,7 +33,7 @@ function  y=num2cell(x,dimens)
         error(msprintf(gettext("%s: Wrong number of input arguments: At least %d expected.\n"),"num2cell",1));
     elseif argn(2)==1 then
         for i=1:size(x,"*")
-            y(i).entries=x(i)
+            y{i}=x(i)
         end
         y=matrix(y,xsize)
         return
@@ -80,7 +80,7 @@ function  y=num2cell(x,dimens)
 
     // fill the cell y
     for i=1:prod(ydims)
-        y(i).entries=matrix(x(1+(i-1)*prodxdimens:prodxdimens*i),ycpdims)
+        y{i}=matrix(x(1+(i-1)*prodxdimens:prodxdimens*i),ycpdims)
     end
     y=matrix(y,ydims)