将两个一维数组转换为一个二维数组--Matlab

时间:2017-05-23 08:14:30

标签: arrays matlab function

我有两个数组,比如 A B 。我想将它转换成一个二维数组。 例如:

A=[1;2;3];
B=[1;2;3];

输出应为

C=[[1,1];[2,2];[3,3]];

有没有MATLAB功能或更简单的方法呢?

1 个答案:

答案 0 :(得分:0)

你必须连接两个向量,最简单的方法是

示例:

import path from 'path';
import webpack from 'webpack';
import eslintFormatter from 'eslint-friendly-formatter';

export default (env) => {
  const isProd = env ? !!env.release : false;
  const isVerbose = env ? !!env.verbose : true;

  process.env.NODE_ENV = isProd ? 'production' : 'development';

  return {
    entry: {
      showcase: path.resolve(process.cwd(), 'src/AppBundle/Resources/private/js/showcase/index.js'),
      // widget: path.resolve(process.cwd(), 'src/AppBundle/Resources/private/js/widget/index.js'),
    },
    output: {
      path: path.resolve(process.cwd(), 'web/dist/components'),
      filename: '[name].js',
      publicPath: '/',
    },
    resolve: {
      extensions: ['.js', '.json', '.vue'],
      alias: {
        Translator: 'node_modules/bazinga-translator/js',
      },
    },
    externals: {
      vue: 'Vue',
      vuex: 'Vuex',
      google: 'google',
      leaflet: 'L',
      translator: 'Translator',
      markerclustererplus: 'MarkerClusterer',
      lodash: '_',
      routing: 'Routing',
    },
    module: {
      rules: [
        {
          test: /\.(js|vue)$/,
          enforce: 'pre',
          include: path.resolve(process.cwd(), 'src/AppBundle/Resources/private/js'),
          use: {
            loader: 'eslint-loader',
            options: {
              formatter: eslintFormatter,
            },
          },
        },
        {
          test: /\.js$/,
          include: path.resolve(process.cwd(), 'src/AppBundle/Resources/private/js'),
          use: 'babel-loader',
        },
        {
          test: /\.vue$/,
          use: 'vue-loader',
        },
      ],
    },
    plugins: [
      // Define environment variables
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify(process.env.NODE_ENV),
        },
      }),

      // No compile changes on errors
      ...isProd ? [] : [new webpack.NoEmitOnErrorsPlugin()],

      // JavaScript code minimizing
      ...isProd ? [
        // Minimize all JavaScript output of chunks
        // https://github.com/mishoo/UglifyJS2#compressor-options
        new webpack.optimize.UglifyJsPlugin({
          sourceMap: true,
          compress: {
            warnings: isVerbose,
          },
        }),
      ] : [],
    ],
    watchOptions: {
      aggregateTimeout: 300,
      poll: 1000,
    },
  };
};

命令窗口输出:

% Create two vector (row wise)
A=[1;2;3];
B=[1;2;3];

% Concatenate the vectors into coloumn
C =[A B]