필터 지우기
필터 지우기

How do i further simplify this solution in matlab. I have used the simplify(.....) but it still gives me the same solution with the sin functions.

조회 수: 3 (최근 30일)
syms z
syms L
syms z1
syms za
z1= 0.5*L;
pi = 3.1412;
L = 33.65;
valueBxx1=int(sin(pi*z1/L)^2 ,z, 0, L);

채택된 답변

Gautam Chettiar
Gautam Chettiar 2022년 11월 1일
The problem is arising in
z1 = 0.5 * L
, as first L is declared as a symbolic variable in
syms L
Later you assign a value to L, and hence it works on integration, however you still have its symbolic form in z1, and hence it returns an answer dependent on L
In short, you arent getting a simplified answer because your answer is an expression with a variable.
Try this:
syms z
syms z1
L = 33.65;
z1= 0.5*L;
pi = 3.1412;
valueBxx1=int(sin(pi*z1/L)^2 ,z, 0, L);
vpa(simplify(valueBxx1),3)

추가 답변 (1개)

John D'Errico
John D'Errico 2022년 11월 1일
편집: John D'Errico 2022년 11월 1일
ARGH!!!!!! Why would you define the value of pi in MATLAB? Worse, then not even defining it to be the correct value?
pi already exists as a variable in MATLAB.
format long
pi
ans =
3.141592653589793
3.1412 is not even correctly rounded!
And worse yet, you are doing symbolic computations!!!!! Why spend the computing power to compute the wrong thing exactly?????
(Excuse me, as I go pound my head against a local brick wall. Ok. Now my head feels much better.)
syms z L z1 za
z1 = 0.5*L;
L = 33.65;
valueBxx1 = int(sin(pi*z1/L)^2 ,z, 0, L)
valueBxx1 = 
What would you want to see there? L is unknown, and it is inside the trig function. The sin of that expression is a FUNCTION OF L. Trig functions are NONLINEAR functions. As such, they have the fundamental property that they CANNOT be simplified. There is little more that could be done with it, since the value of L is unknown.
Could you force MATLAB to rewrite that expression using say a double angle formula for sin(x)^2? So I suppose we could use an identity like:
sin(u)^2 = (1 - (cos(2*u))/2
It will still have a cosine function of L. What more would you want to see?
simplify(valueBxx1,'steps',10,'all',true)
ans = 
So the second of those choices does not have the square of a sine function in it. Is it materially different?

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by