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일
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 Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

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