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

1 次查看(过去 30 天)
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

回答(1 个)

Andy
Andy 2020-2-24
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.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by