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.

Risposte (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)]
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.

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Tag

Richiesto:

il 14 Mar 2021

Risposto:

il 14 Mar 2021

Community Treasure Hunt

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

Start Hunting!

Translated by