Convert multi-cell array to matrix

4 ビュー (過去 30 日間)
PATRICK WAYNE
PATRICK WAYNE 2018 年 2 月 14 日
コメント済み: PATRICK WAYNE 2018 年 2 月 14 日
Forgive my ignorance, but I am having a problem. I am analyzing pressure traces from an experiment and I need help converting a multi-cell array to a matrix. So, for instance, I have a 1 X 19 cell array and in each of the 19 cells is a 600 x 1 double. I want to convert the 1 x 19 cell array to a 600 x 19 matrix. I can easily do it if each cell is a single value, using cell2mat. But I cannot figure out how to do it for this cell array. I'm missing something, but I don't know what. I thought of running cell2mat in a for-loop but that didn't work. I tried cellfun, but couldn't get that to work either.
Any help would be appreciated.

採用された回答

PATRICK WAYNE
PATRICK WAYNE 2018 年 2 月 14 日
Nevermind, I just figured it out. I have used cell2mat before, multiple times, trying to get this to work. I guess I coded it wrong because I accomplished it with one simple line:
T1 = cell2mat(pressure))
That was it. I must've had a brain fart. I think I was trying to save each cell into a separate matrix, which didn't work.
  1 件のコメント
PATRICK WAYNE
PATRICK WAYNE 2018 年 2 月 14 日
Ok, so this is why I'm frustrated. I went ahead and coded in all the cell arrays and it didn't work.............AGAIN. For some reason, it will not work if I only run that particular section. But, it does work if I run the entire m-file. WTF? These lines are not inside any loops. This is very odd and caused me to waste about 4 hours........

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by