Create a cell with row vectors as elements

조회 수: 1(최근 30일)
Ace
Ace 2022년 8월 8일
댓글: Ace 2022년 8월 9일
Hi there! I am new to Matlab. I have ten 64x64x10 matrices named from A to J. What I want to do is to combine them so that each element of a new array is a vector containing the corresponding elements of each matrix (an array consisting of 64x64x10 10x1 vectors). So far I constructed such an array using the piece of code shown below. However, the problem is I wanted each cell to be represented by a column vector, not row vector. I also tried cellfun to transpose individual cells, but it seems not to work properly. Any advice would be highly appreciated.
S=arrayfun(@(a,b,c,d,e,f,g,h,i,j) num2str([a b c d e f g h i j]), A,B,C,D,E,F,G,H,I,J, 'un',0);
  댓글 수: 2
Ace
Ace 2022년 8월 8일
Thanks for that answer, it makes the solution closer, but I've just found out that the data type in the array is now "text" (string/char), not numeric. What I need is to have a set of 64x64x10 true column vectors (I'm trying to use those column vectors to fit certain sort of data to a curve). Any idea?
Error message:
Error using fit>iFit
Y must be a column vector.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2022년 8월 8일
편집: Stephen23 2022년 8월 9일
F = @(varargin) vertcat(varargin{:});
C = arrayfun(F, A,B,C,D,E,F,G,H,I,J, 'uni',0);
  댓글 수: 1
Ace
Ace 2022년 8월 9일
Thanks! Seems to work fine :).

댓글을 달려면 로그인하십시오.

추가 답변(0개)

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by