Convert a structure array to a list

63 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2021 年 3 月 10 日
コメント済み: Aleem Andrew 2021 年 3 月 11 日
I am trying to convert a structure array into a list rather than a cell to be able to perform operations such as finding the inverse Laplace of each of the elements more easily as with the list x below.
syms s
x = [(11816914992063660*s)/(18014398509481984*s^2 + 3567972556901945); -(6638091741507548*s)/(4503599627370496*s^2 + 7002908864245409);...
(2661668130624680*s)/(2251799813685248*s^2 + 7311548066690791)];
ilaplace(x)
In the following code I want to find the inverse Laplace of each of the elements of the structure array sol.
syms s r1 r2 r3
r = [r1 r2 r3];
eqns = [r1*s^2 - 0.65597*s + 0.19806*r1 == 0.0, r2*s^2 + 1.474*s + 1.555*r2 == 0.0,...
r3*s^2 - 1.182*s + 3.247*r3 == 0.0];
sol = solve(eqns,r);
Converting sol to a cell array with struct2cell causes an error message if you type ilaplace(sol) to find the inverse Laplace of each element. Is there a way to convert the structure array sol to a list so this can be done?
  2 件のコメント
Stephen23
Stephen23 2021 年 3 月 11 日
"I am trying to convert a structure array into a list rather than a cell..."
MATLAB does not have a "list" type.
What code did you try and what is the exact error message you are getting?
Aleem Andrew
Aleem Andrew 2021 年 3 月 11 日
I meant a double type. I tried struct2cell(sol) and then ilaplace(sol) which led to an error message which would not happen if sol could be converted to a double.

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

採用された回答

Jorg Woehl
Jorg Woehl 2021 年 3 月 11 日
編集済み: Jorg Woehl 2021 年 3 月 11 日
c = struct2cell(sol);
ilaplace([c{:}].')
  1 件のコメント
Aleem Andrew
Aleem Andrew 2021 年 3 月 11 日
Thank you for your answer

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by