Process on Matrices (addition, multiplication, ...)

how can i define a matricies A and B in MATLAB, there elements are a function of x, as in the following.

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 3 月 14 日

0 投票

syms f_11(x) f_12(x) f_21(x) f_22(x) g_11(x) g_12(x) g_21(x) g_22(x)
A = [f_11(x) f_12(x); f_21(x) f_22(x)]
A = 
B = [g_11(x) g_12(x); g_21(x) g_22(x)]
B = 
If you have sufficiently new MATLAB (R2020b or later I think it is)
clearvars
syms f(t) [2 2]
syms g(t) [2 2]
all_syms = syms();
A = subs(reshape(all_syms(~cellfun(@isempty, regexp(all_syms, '^f\d'))), [2 2]))
A = 
B = subs(reshape(all_syms(~cellfun(@isempty, regexp(all_syms, '^g\d'))), [2 2]))
B = 
Which is to say that you can automatically construct the indexed functions now, but there is no good way to collect them in a variable.

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

質問済み:

2021 年 3 月 14 日

回答済み:

2021 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by