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

1 回表示 (過去 30 日間)
Debasish Mishra
Debasish Mishra 2020 年 2 月 24 日
回答済み: Andy 2020 年 2 月 24 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by