フィルターのクリア

Creating a symbolic array

2 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 11 月 24 日
コメント済み: Aleem Andrew 2020 年 11 月 25 日
When I tried to create an array consisting of expressions in terms of a symbolic variable I get the error message
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
But I don't want to evaluate the expressions at a particular value. Instead I want expressions in terms of the symbolic variable q. Does anyone have suggestions regarding how this can be done?
syms q
a = [];
for i = 1:5
for j = 1:5
a(i,j) =q;
end
end

採用された回答

Walter Roberson
Walter Roberson 2020 年 11 月 25 日
a = sym([]);
or better yet
a = zeros(5,5,'sym')
  1 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 11 月 25 日
Thanks for your answer

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

その他の回答 (2 件)

Stephan
Stephan 2020 年 11 月 24 日
編集済み: Stephan 2020 年 11 月 24 日
>> q = sym('q', [5, 5])
q =
[ q1_1, q1_2, q1_3, q1_4, q1_5]
[ q2_1, q2_2, q2_3, q2_4, q2_5]
[ q3_1, q3_2, q3_3, q3_4, q3_5]
[ q4_1, q4_2, q4_3, q4_4, q4_5]
[ q5_1, q5_2, q5_3, q5_4, q5_5]
>> whos q
Name Size Bytes Class Attributes
q 5x5 8 sym
>> q(1,1:end) = 42
q =
[ 42, 42, 42, 42, 42]
[ q2_1, q2_2, q2_3, q2_4, q2_5]
[ q3_1, q3_2, q3_3, 42, q3_5]
[ q4_1, q4_2, q4_3, q4_4, q4_5]
[ q5_1, q5_2, q5_3, q5_4, q5_5]

Steven Lord
Steven Lord 2020 年 11 月 25 日
If you want an array of q's:
syms q
A = repmat(q, [5 5])
A = 

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Preferences についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by