Cell array to matix

4 ビュー (過去 30 日間)
Praveen Kumar Ramani
Praveen Kumar Ramani 2019 年 1 月 31 日
コメント済み: Guillaume 2019 年 1 月 31 日
i have cell array of 1x112 cell
each cell consists of mx3 matix
i want to get all matix in the cell array as seprate martrix in workspace
  6 件のコメント
Praveen Kumar Ramani
Praveen Kumar Ramani 2019 年 1 月 31 日
Sir i have loaded in workspace,
i want each matix from a cell array to be separated as a single single matix which should be appear in my workspace
madhan ravi
madhan ravi 2019 年 1 月 31 日
OK , upload your data file,
Remark: As seen from the picture each cell has different matrix sizes.
Target: When you say separate matrix what do you want the size of each matrix to be , remember each should have the same size when concatenated along the third dimension. If you say it should have the same size as the original form then keeping it as cell is the only way. So your call..

サインインしてコメントする。

回答 (2 件)

Ollie A
Ollie A 2019 年 1 月 31 日
編集済み: Ollie A 2019 年 1 月 31 日
You could try using:
M = {}; % Your cell
N = cat(3,M{:}); % Concatenate matrices along 3rd dimension
This will give you a single matrix rather than 112 separate matrices.
  1 件のコメント
Praveen Kumar Ramani
Praveen Kumar Ramani 2019 年 1 月 31 日
have cell array of 1x112 cell
each cell consists of matix of variable sizes
i want to get all matix in the cell array as seprate martrix or array in matlab workspace
plz find pic

サインインしてコメントする。


Guillaume
Guillaume 2019 年 1 月 31 日
編集済み: Guillaume 2019 年 1 月 31 日
"i want to get all matix in the cell array as seprate martrix in workspace"
The follow-ups to that question will be how do I create the variable names dynamically, how do I loop over all these variables or something similar.
The answer: Don't do that. Your matrices are perfectly usable as they are. You don't need them as separate variables, it is much easier to keep them as a cell array. Dynamically creating 112 different variables would be madness. It would be slow, hard to debug and you wouldn't be able to use them efficiently.
If you explain what you want to do with these 112 matrices, we can show you how to use that cell array properly.
  2 件のコメント
Praveen Kumar Ramani
Praveen Kumar Ramani 2019 年 1 月 31 日
I want all the matrix one by one to be an input for matlab function
Guillaume
Guillaume 2019 年 1 月 31 日
Trivially done with a cell array:
for i = 1:numel(Microtrips)
result = somefunction(Microtrips{i}) %call function with each matrix in turn.
%... some more code
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by