creating 2 by 2 matrices having 3 entries same in all but 4th one different

1 Ansicht (letzte 30 Tage)
i want to create a series of matices m1,m2,m3,m4 etc such that
m1=[1 0; 0 f(x1)]
m2=[1 0;0 f(x2)]
and so on.(only 22 entry is having a functional value and other 3 entries remain same.
x=[x1 x2 x3.....]
f is any arbitrary function.
and i also need to find out how to multiply all the above matrices such that m=m1*m2*m3.......*mn
kindly help

Antworten (1)

Andy
Andy am 24 Feb. 2020
Rather than using numbers as part of the variable name use a cell structure
m{1} = [1 0; 0 f(x(1))]
You can then easily use a loop to generate the initial matrices and multiply them.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by