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

1 visualización (últimos 30 días)
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

Respuestas (1)

Andy
Andy el 24 de Feb. de 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.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by