numerical answer required for sumation
조회 수: 8 (최근 30일)
이전 댓글 표시
a very basic question, say i use
symsum(((-1)^(sym('k')-1))*(sin(sym('k'))), k, 0, 12)
I just get
sin(311/250) - sin(311/125) - sin(311/625) - sin(622/625) - sin(933/625) + sin(311/1250) - sin(1244/625) + sin(933/1250) - sin(1866/625) + sin(2177/1250) + sin(2799/1250) + sin(3421/1250)
but i want a single numeric value (like 0.2354 or whatever) not this expanded string of sin's. I dont want like 0.254 +0.056 +0.214 etc I just want a single value.
Ive tried searching on google but i have the normal problem of not knowing what the keyword is to search for.
댓글 수: 0
채택된 답변
Walter Roberson
2011년 3월 2일
You can apply double() to a symbolic expression to get back the Matlab double precision number that is equivalent.
If you want the result to be a symbolic number instead, such as if you need to evaluate to more decimal places, then use vpa() on the symbolic expression.
댓글 수: 0
추가 답변 (2개)
Paulo Silva
2011년 3월 2일
double(sin(311/250)-sin(311/125)-sin(311/625)-sin(622/625)-sin(933/625)+sin(311/1250)-sin(1244/625)+sin(933/1250)-sin(1866/625)+sin(2177/1250)+sin(2799/1250)+sin(3421/1250))
댓글 수: 0
Paulo Silva
2011년 3월 2일
eval('sin(311/250)-sin(311/125)-sin(311/625)-sin(622/625)-sin(933/625)+sin(311/1250)-sin(1244/625)+sin(933/1250)-sin(1866/625)+sin(2177/1250)+sin(2799/1250)+sin(3421/1250)')
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!