Writing a function with variable outputs to convert a 3d matrix to 2d
古いコメントを表示
Hello, so I'm very new to Matlab so my apologies if this is a very simple question. I have a 3d matrix for example sized 40x2x4. I want to be able to split this into multiple 2d matrices, so for example a = (:,1,1), b = (:,1,2), c = (:,2,1), d = (:,2,2) etc. However, the dimensions are often variable, so I'm unsure of how to create a function that will create a variable number of outputs depending on the dimensions of the input matrix. I've found varargout, but I'm unsure of if this is what I need and if it is, I'm not sure of how exactly to use it. Thanks for any help here, I really appreciate it! -Jesse
回答 (2 件)
Sean de Wolski
2012 年 3 月 8 日
No. Your inner-conscience is actually telling you that you don't want to do that!
doc mat2cell %is probably closer what you want
Welcome to MATLAB and Answers
Walter Roberson
2012 年 3 月 8 日
0 投票
See blockproc() or blkproc() or mat2cell() for the splitting and processing. (You often do not need to explicitly split the matrix.)
You do not want to create a variable number of outputs for this situation, as writing an assignment statement that has a variable number of left-hand sides is an advanced MATLAB technique.
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!