Hello, I have a 4*4 cell array that has a 10*10 matrix within each cell like below (let's call it C):
C=
And two 10*10 separate matrices let's say:
A=rand(10,10);
B=rand(10,10);
Using these 3 arguments, I want do an operation like below:
(A*C-B*C)/((C^2)*C*(1+(B/C)^2))^(1.5)
Basically, I want to consider each component of the cell (for example C{1} for the first attempt) and do this operation with the B and C for every 16 components of the cell in a repetitive manner. How can I perform this operation? I would appreciate it if someone could please help me. Thank you.

 採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 7 月 9 日

1 投票

for ii=1:4
for jj=1:4
ANS{ii,jj} = (A*C{ii,jj}-B*C{ii,jj})/((C{ii,jj}.^2).*C{ii,jj}.*(1+(B./C{ii,jj}).^2)).^(1.5);
end
end

5 件のコメント

MarshallSc
MarshallSc 2021 年 7 月 9 日
Thanks for your answer, but I tried this operation and the results are NaN:
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 7 月 9 日
Firt of all, the results depend on your C array data and whether you need to perform the matrix operation (1) or elementwise operation (2) e.g.:
%% (1) Matrix multiplication and division
for ii=1:4
for jj=1:4
ANS{ii,jj} = (A*C{ii,jj}-B*C{ii,jj})/((C{ii,jj}^2)*C{ii,jj}*(1+(B/C{ii,jj})^2))^(1.5);
end
end
vs.
%% (2) ELementwise multiplication and division
for ii=1:4
for jj=1:4
ANS{ii,jj} = (A.*C{ii,jj}-B.*C{ii,jj})/((C{ii,jj}.^2).*C{ii,jj}.*(1+(B./C{ii,jj}).^2)).^(1.5);
end
end
MarshallSc
MarshallSc 2021 年 7 月 9 日
I just figured it out, thank you so much again.
MarshallSc
MarshallSc 2021 年 7 月 9 日
I already did sir. Thank you.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 7 月 9 日
You are most welcome! All the best!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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