Multiplication of a matrix with 6x6 cell.

7 ビュー (過去 30 日間)
M.Bilal
M.Bilal 2020 年 2 月 1 日
コメント済み: M.Bilal 2020 年 2 月 3 日
Here, i want to multply matrix with 6x6 cell array, but the error occurs. How can i solve this?
Here
S_m is 6x6 cell array
I2 is 1x6 matrix, I2=[1 1 1 0 0 0]
In order to multiply both, following code is used:
(error included)
S_dg = cellfun(@times,S_m,num2cell(I2),'uni',false); %to multiply matrix I2(1x6) with cell array 6x6
Error using cellfun
All of the input arguments must be of the same
size and shape.
Previous inputs had size 6 in dimension 1.
Input #3 has size 1

採用された回答

Stephen23
Stephen23 2020 年 2 月 1 日
Use an anonymous function instead:
fun = @(m) m.*I2;
S_dg = cellfun(fun,S_m,'uni',false);
  2 件のコメント
M.Bilal
M.Bilal 2020 年 2 月 1 日
Thankyou again sir, for your effective answer...
M.Bilal
M.Bilal 2020 年 2 月 3 日
1 question more,
How to solve equation which consist of cell array 6x6, matrices and variables?
e.g
S_eff = S_d + (((S_d - S_m) * I6 * (S_d - S_m))/(phi*(I2*S_m*I2' - 1/k_f) - I2*(S_d - S_m)*I2'));
% Here, S_d,S_m, are 6x6 cell array while phi and 1/k_f are single values say phi=0.2, k_f=2
% I2 =[1 1 1 0 0 0]; 1x6 matrix
% I6 = I2'*I2; 6x6 matrix

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by