필터 지우기
필터 지우기

sum calculation in matlab

조회 수: 3 (최근 30일)
MariapL
MariapL 2017년 11월 19일
댓글: Star Strider 2017년 11월 21일
Hi, I have problem starting calculation of this sum
SUM(ZnSn-aSnSn+bSnTn)=0
Sum(ZnTn-aSnTn+bTnTn)=0
So I have S1 S2 S3 Z1 Z2 Z3 T1 T2 T3
I need to calculate a and b. I kinda can do it on paper by the point is to see how matlab calculate it. It should go like
Z1S1-aS1S1+bS1T1 + Z2S2-aS2S2+bS2T2 + Z3S3-aS3S3+b32T3=0
Z1T1-aS1T1+bT1T1 + Z1T1-aS1T1+bT1T1 +Z1T1-aS1T1+bT1T1 =0
How should I start it, I m super new at matlab. Should I use sum , and set a and b as vector of 0 ? Any help much appreciated

답변 (2개)

Star Strider
Star Strider 2017년 11월 19일
Note that ‘32T3’ is not a valid MATLAB variable name (they cannot begin with numbers). I changed it to ‘S2T3’, and used the Symbolic Math Toolbox:
syms a b Z1S1 S1S1 S1T1 Z2S2 S2S2 S2T2 Z3S3 S3S3 S2T3 Z1T1 T1T1
Eqns = [Z1S1-a*S1S1+b*S1T1 + Z2S2-a*S2S2+b*S2T2 + Z3S3-a*S3S3+b*S2T3 == ...
Z1T1-a*S1T1+b*T1T1 + Z1T1-a*S1T1+b*T1T1 +Z1T1-a*S1T1+b*T1T1];
[a,b] = solve(Eqns, [a b])
to produce:
a =
(S1T1*Z1T1 + S2T2*Z1T1 + S2T3*Z1T1 - T1T1*Z1S1 - T1T1*Z2S2 - T1T1*Z3S3)/(S1T1*S2T2 + S1T1*S2T3 - S1S1*T1T1 - S2S2*T1T1 - S3S3*T1T1 + S1T1^2)
b =
(S1S1*Z1T1 - S1T1*Z1S1 + S2S2*Z1T1 - S1T1*Z2S2 + S3S3*Z1T1 - S1T1*Z3S3)/(S1T1*S2T2 + S1T1*S2T3 - S1S1*T1T1 - S2S2*T1T1 - S3S3*T1T1 + S1T1^2)
I have no idea if these will produce usable results, since I do not know what any of the variables are (scalars, matrices, ...).
  댓글 수: 2
MariapL
MariapL 2017년 11월 21일
Is there any way to not include 'syms'? I have tried to intall it couple of time but still got an error. Thanks:)
Star Strider
Star Strider 2017년 11월 21일
You do not need to use the Symbolic Math Toolbox. I used it to solve for ‘a’ and ‘b’, so all you need to do is to use the equations I provided, with your numeric variables, to find the parameter values.

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


Torsten
Torsten 2017년 11월 21일
If you define Z, S, T as numerical arrays, you can determine a and b as
A = [-sum(S.*S) sum(S.*T);-sum(S.*T) sum(T.*T)];
rhs = [-sum(Z.*S);-sum(Z.*T)];
x = A\rhs;
a = x(1);
b = x(2);
a
b
Best wishes
Torsten.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by