How to convert a cell array that contains inside durations to a duration array

Hi, so thats my problem I got a cell array that contain inside a group of duration and I want to split this group of duration to not have the cells. How can I do it? I post the variable so you can see easely what I mean.

1 件のコメント

Stephen23
Stephen23 2022 年 2 月 11 日
編集済み: Stephen23 2022 年 2 月 11 日
Do not use a loop for this. The MATLAB approach is to use a comma-separated list, for example one of:
out = horzcat(All_Time_msg_dist_Max{:})
out = vertcat(All_Time_msg_dist_Max{:})

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

 採用された回答

Benjamin Thompson
Benjamin Thompson 2022 年 2 月 10 日

0 投票

Not very elegant but the brute force way to copy from your cell array to a duration array:
A = All_Time_msg_dist_Max{1};
for i = 1:length(All_Time_msg_dist_Max)
A(:,i) = All_Time_msg_dist_Max{i};
end

4 件のコメント

flashpode
flashpode 2022 年 2 月 10 日
That makes me a variable of 2x496 and what I want is to get all the values in one column
Benjamin Thompson
Benjamin Thompson 2022 年 2 月 10 日
Ok you did not state this requirement. If you type A(:) you will get everything in one column.
This command would transpose the two rows of A and combine them together into a one column B variable:
B = [A(1,:)'; A(2,:)'];
If you want things arranged differently you can alter these commands in many ways.
flashpode
flashpode 2022 年 2 月 10 日
but this is gonna give me the second column after the first one? couse what I want is to get both durations of the cell consecutive.
flashpode
flashpode 2022 年 2 月 10 日
Okay Its already done. I used duration.empty
thank you

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

質問済み:

2022 年 2 月 10 日

編集済み:

2022 年 2 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by