Help! About use symsum on matrix

Hello, i am a freshman on matlab
it's a problem about summation of matrix
m=2;
p=[2,3;3,5]; %matrix 2*2
yu=[34;44]; %column vector 2*1
syms t;
rt=symsum((p^t)*yu,t,0,m);
what i want should be the followings:
>> (p^0)*yu+ (p^1)*yu+ (p^2)*yu
ans =
1600
2576
however, i get this
>> rt
rt =
matrix([[102, 102], [102, 204]])
matrix([[132, 132], [132, 264]])
I don't know why
Please help me
Thanks a lot!

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 5월 7일

0 개 추천

variant without symbolic toolbox
a = arrayfun(@(x)p^x*yu,0:2,'un',0);
rt = sum([a{:}],2)

댓글 수: 2

zhang
zhang 2011년 5월 7일
thank u
urs are right
however, i still want to know how to use symsum to fix it and what is the meaning of "variant without symbolic toolbox" ?
sorry
i do a freshman on matlab
Andrei Bobrov
Andrei Bobrov 2011년 5월 7일
symsum function from Symbolic Math Toolbox (doc symsum)
Your task to solves symsum Maple Toolbox for MATLAB, for its installation, you must have Maple

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Paulo Silva
Paulo Silva 2011년 5월 7일

0 개 추천

Your are missing a dot before the exponent
rt=symsum((p.^t)*yu,t,0,m);

댓글 수: 5

zhang
zhang 2011년 5월 7일
according to ur answer, i got this
>> rt
rt =
278
400
yes, it's has no matrix things, but the answer is not right
it should be like this
>> (p^0)*yu+ (p^1)*yu+ (p^2)*yu
ans =
1600
2576
Paulo Silva
Paulo Silva 2011년 5월 7일
I can't find the problem, if you do
syms t p yu
rt=symsum((p.^t)*yu,t,0,m)
you get the same expressions (p^0)*yu+(p^1)*yu+(p^2)*yu
but with p and yu replaced by the array it's not the same, sorry
Paulo Silva
Paulo Silva 2011년 5월 7일
also if you choose m=0 it should give yu but it gives [78;78] , 78 is the sum of yu values
zhang
zhang 2011년 5월 7일
maybe i did not express it clear
your suggestion of adding dot before exponent which is another different multiplication operator of matrix
for example
>> A=[1,2;2,3]
A =
1 2
2 3
>> B=A.^2
B =
1 4
4 9
>> C=A^2
C =
5 8
8 13
you see, they are two different operator
zhang
zhang 2011년 5월 8일
Operation Operator Syntax M-Function Equivalent
Matrix power A^B mpower(A,B)
Arraywise power A.^B power(A,B)
you can search word "mpower" in the help
and "Arithmetic Operators + - * / \ ^ '" explain well
thank ur answer

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by