Java Array Convert to arrayToMatlabStringArray(double da[])

Here you can find the source of arrayToMatlabStringArray(double da[])

Description

array To Matlab String Array

License

Apache License

Declaration

public static String arrayToMatlabStringArray(double da[]) 

Method Source Code

//package com.java2s;
/*/*from  www.  ja  v a2 s  .co  m*/
 * Copyright 2009 the original author or authors.
 * Copyright 2009 SorcerSoft.org.
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static String arrayToMatlabStringArray(double da[]) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < da.length; i++) {
            sb.append(da[i]);
            if (i + 1 < da.length)
                sb.append(",");
        }
        sb.append("]");
        return sb.toString();
    }

    public static String arrayToMatlabStringArray(Object da[]) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < da.length; i++) {
            sb.append(da[i]);
            if (i + 1 < da.length)
                sb.append(",");
        }
        sb.append("]");
        return sb.toString();
    }
}

Related

  1. arrayToJava(double[] v, int off, int len, String name)
  2. arrayToJson(int[] x)
  3. arrayToLine(Object[] source)
  4. arrayToLines(String[] lines)
  5. arrayToLowercase(String[] array)
  6. arrayToOneLineSpaceDelimitedString(Object obj[])
  7. arrayToQueryString(String key, Object[] arr)
  8. arrayToSeparatedString(final String[] strings, final String separator)
  9. arrayToSqlInList(String... values)