Asked by masoud jiryaei
on 4 Sep 2019

I have the matrix [A]= [ a*(x^2)+y , b(y^3)+x ; d*(x^2)*y , c*y ].

and I have the matrix [B]=[1 2;3 4] which the first column of [B] is x and the socond culomn Of [B] is y .

I want to put x=1 and y=2 then x=3 and y=4 and sum A11. then do it for other cells.

Answer by madhan ravi
on 4 Sep 2019

Edited by madhan ravi
on 4 Sep 2019

Accepted Answer

syms a b c d

B = [ 1 2 ; 3 4] ;

x = reshape(B(:,1),1,1,[]);

y = reshape(B(:,2),1,1,[]);

A = [ a*(x.^2)+y , b*(y.^3)+x ; d*(x.^2).*y , c*y ] ;

a = arrayfun(@(z) sum(sum(A(:,:,z))), 1:size(A,3),'un',0);

celldisp(a)

Sign in to comment.

Answer by KSSV
on 4 Sep 2019

syms a b c d

B = [ 1 2 ; 3 4] ;

x = B(:,1) ;

y = B(:,2) ;

A = [ a*(x(1)^2)+y(1) , b*(y(1)^3)+x(1) ; d*(x(2)^2)*y(2) , c*y(2) ] ;

iwant = sum(A(:))

masoud jiryaei
on 4 Sep 2019

excuse me you i mean : A11=(a*(1)^2 + 2)+(a*(3)^2 + 4)

A12=...

A21=...

A22=...

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## madhan ravi (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/478792-how-can-i-put-some-numbers-in-a-sym-and-sum-its-cells#comment_741944

## masoud jiryaei (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/478792-how-can-i-put-some-numbers-in-a-sym-and-sum-its-cells#comment_741947

Sign in to comment.