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개)
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)]
B = [g_11(x) g_12(x); g_21(x) g_22(x)]
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]))
B = subs(reshape(all_syms(~cellfun(@isempty, regexp(all_syms, '^g\d'))), [2 2]))
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!