Unable to convert expression containing symbolic variables into double array error

31 ビュー (過去 30 日間)
I am trying to define a vector xdd in terms of another vector x but when I define elements of the vector xdd in terms of the corresponding elements of x I get the error
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first
to substitute values for variables.
Can someone please suggest a way to solve this problem?
syms x1 x2 s t
x = [x1; x2];
xdd = [];
for i = 1:length(x0)
xdd(i) = s^2*x(i) + 2*sin(t)
end

採用された回答

Star Strider
Star Strider 2021 年 3 月 9 日
Create ‘xdd’ as a cell array instead:
xdd{i} = s^2*x(i) + 2*sin(t)
That works.
  2 件のコメント
Aleem Andrew
Aleem Andrew 2021 年 3 月 10 日
Thank you for your answer
Star Strider
Star Strider 2021 年 3 月 10 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by