How to take Inverse of a 6x6 cell array in MATLAB?

3 views (last 30 days)
M bilal
M bilal on 16 Sep 2020
Edited: M bilal on 16 Sep 2020
I have a 6x6 cell array(C_dry ). Each element in this array is 142x1 matrix.
How to take inverse of this array?
C_dry = {A B F 0 0 0
B A F 0 0 0
F F C 0 0 0
0 0 0 D 0 0
0 0 0 0 D 0
0 0 0 0 0 M}; %6x6 cell array
When i run below command
S_d = pinv(C_dry);
follwoing error appears,
Undefined function 'svd' for input arguments
of type 'cell'.
Error in pinv (line 18)
[U,S,V] = svd(A,'econ');
  2 Comments
Stephen23
Stephen23 on 16 Sep 2020
"I have a 6x6 cell array(C_dry ). Each element in this array is 142x1 matrix. How to take inverse of this array?"
What is your definition of "inverse" for a cell array where each cell contains a 142x1 matrix?
M bilal
M bilal on 16 Sep 2020
i finally understood , inverse will not work for this so of transpose. i can only use follwoing,in order to get rid of this problem
S_d = C_dry;

Sign in to comment.

Answers (2)

madhan ravi
madhan ravi on 16 Sep 2020
Assuming by inverse you mean transpose :
C_dry = cellfun(@transpose, C_dry, 'un', 0)
  7 Comments
Walter Roberson
Walter Roberson on 16 Sep 2020
What size and datatype of output are you hoping for?
M bilal
M bilal on 16 Sep 2020
Edited: M bilal on 16 Sep 2020
after inverse, i need C_dry as a 6x6 cell, having each element asa 142x1 double datatype column matrix.

Sign in to comment.


Walter Roberson
Walter Roberson on 16 Sep 2020
If you just happen to mean that you want to take
C_dry(K) = pinv([
A(K) B(K) F(K) 0 0 0
B(K) A(K) F(K) 0 0 0
F(K) F(K) C(K) 0 0 0
0 0 0 D(K) 0 0
0 0 0 0 D(K) 0
0 0 0 0 0 M(K)
])
for all 142 values, then:
syms A_ B_ F_ C_ D_ M_
C_dry_ = simplify(pinv([A_ B_ F_ 0 0 0; B_ A_ F_ 0 0 0; F_ F_ C_ 0 0 0; 0 0 0 D_ 0 0; 0 0 0 0 D_ 0; 0 0 0 0 0 M_]));
D3 = @(M) reshape(M,1,1,[]);
C_dry = subs(C_dry_, {A_, B_, C_, D_, F_, M_}, {D3(A), D3(B), D3(C), D3(D), D3(F), D3(M)});
The resulting C_dry would be 6 x 6 x numel(A)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!