MATLAB Answers

Converting a comma separated list into an array concatenates them.

7 ビュー (過去 30 日間)
Arya Das
Arya Das 2020 年 6 月 19 日
回答済み: Atul Upadhyay 2020 年 6 月 19 日
I was trying to convert a comma separated list of strings into a normal array. So B0005.cycle is a struct with some fields:
B0005.cycle.type is a comma separated list:
I tried to convert it into an array by doing this: [B0005.cycle.type] but it gives this output:
However I want ["charge", "discharge","charge","discharge",...]. So how do I go about this?
I have attached the mat file below.

  0 件のコメント

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

採用された回答

Atul Upadhyay
Atul Upadhyay 2020 年 6 月 19 日
I can see that you are trying to convert a comma separated list of strings to normal array. You can do it like following.
arr={B0005.cycle.type};
newarr=[];
for x=arr
newarr=[newarr; string(x{1})];
end
Refer to the following documentation to know more about comma-separated lists in MATLAB.

  0 件のコメント

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

その他の回答 (0 件)

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by