Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Optics

Optics

Topics related to Speos.

有没有matlab中像cat一样的函数,可以串联元胞数组中的矩阵,以便将元胞数组中每个矩阵

TAGGED: 

    • S1120223150009655
      Subscriber

      各位老师好,请教一下lemerrical中有没有matlab中的cat一样的函数,可以用于串联元胞数组中的矩阵,以便将元胞数组中每个矩阵(同维)的每个维的值加起来。

      matlab中:

      <

      sum(cat(3,A{:}),3)
       
      ans =
       
          15    18
          21    24
      我需要在fdtd里写出来。
    • Guilin Sun
      Ansys Employee

      从这个链接看 Concatenate arrays - MATLAB cat (mathworks.com)

      相当于把第二个矩阵加到第一个矩阵后面产生新的矩阵。

      遗憾,没有。你需要先定义一个新矩阵,大小是两个矩阵长度的和,然后将这两个矩阵分别赋值给新矩阵,比如

      A1 长n1; A2 长n2,则需要

      A3=matrix(n1+n2);

      A3(1:n1)=A1;

      A3(n1+1,n1+n2)=A2;

      你试一下。高维的也采用类似方法,当然也可以将高维压缩为一维,然后再Reshape。

      https://optics.ansys.com/hc/en-us/articles/360034925873-reshape-Script-command

       

Viewing 1 reply thread
  • The topic ‘有没有matlab中像cat一样的函数,可以串联元胞数组中的矩阵,以便将元胞数组中每个矩阵’ is closed to new replies.
[bingo_chatbox]