Create a cell with row vectors as elements

2 views (last 30 days)
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 Comments
Ace
Ace on 8 Aug 2022
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.

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 8 Aug 2022
Edited: Stephen23 on 9 Aug 2022
F = @(varargin) vertcat(varargin{:});
C = arrayfun(F, A,B,C,D,E,F,G,H,I,J, 'uni',0);

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!