댓글 수: 1

Hi @Aditya Zade, if you wish to call a specific user for help, you can use this special character "@".
You can also type out the integrand function in MATLAB by clicking the indentation icon .
For example
% declare symbols
syms t
% assign a value
w_g = 120*pi;
% create a function
func = - sin(w_g*t - pi/6)
func = 

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

 채택된 답변

Walter Roberson
Walter Roberson 2025년 3월 6일

0 개 추천

% declare symbols
syms t
Pi = sym(pi);
% assign a value
w_g = 2*Pi*60;
% create a function
func = - sin(w_g*t - Pi/6) .* sin(w_g*t) / sin(w_g * t - 2*Pi/3)
func = 
Integration = simplify(3*w_g/Pi * int(func, t, 0, 3*w_g, hold=true))
Integration = 
F = matlabFunction(Integration);
format long g
INT = F()
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.9e+04. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
INT =
-21492.6584717154

댓글 수: 7

@Aditya Zade, if you plot the integrand function, you can see the oscillatory singularities (division-by-zero) repeat at regular intervals along the time-axis.
w_g = 120*pi;
func = @(t) - sin(w_g*t - pi/6).*sin(w_g*t)./sin(w_g*t - 2*pi/3);
t = linspace(0, 0.1, 10001);
plot(t, func(t)), ylim([-250 250]), grid on
xlabel('Time')
Aditya Zade
Aditya Zade 2025년 3월 6일
Hi @Sam Chak, thank you for the clarification. However, I am trying to integrate from t=0 to t=1/360 where the function is continuous. So, I thought I could integrate it.
Sam Chak
Sam Chak 2025년 3월 6일
Mathematica also produced the same result as MATLAB. You can follow the example provided by @Walter Roberson. The integrand function is likely intended to differ from yours to encourage you to learn how to write the code independently.
This will reinforce your memory in learning how to calculate definite integrals (the area under a curve between two fixed limits) in MATLAB.
@Aditya Zade, you can also try the integral() function.
% integrand
fun = @(x) 5*sech(5*x).^2;
lb = -1; % lower limit
ub = 1; % upper limit
% Evaluate the integral from x = -1 to x = 1.
q = integral(fun, lb, ub)
q = 1.9998
This did the job in matlab:
wg = 2 * pi * 60 ;
syms time real
func = -sin( ( wg * time ) - ( pi / 6 ) ) * sin( ( wg * time ) - ( pi / 6 ) ) * sin( wg * time ) / sin( ( wg * time ) - ( 2 * pi / 3 ) )
func = 
Integration = simplify( ( 3 * wg / pi ) * int( func, time, 0, pi / ( 3 * wg ) ), 1000 )
Integration = 
Thank you both of you for the help.
Aditya Zade
Aditya Zade 2025년 3월 6일
This is what I am getting: 1/4 - (3*3^(1/2))/(8*pi)
If you attempt to solve a mathematical equation or an integral problem using functions from the Symbolic Math Toolbox, the answers will be returned as symbolic expressions.
format long
Integration = 1/4 - (3*3^(1/2))/(8*pi)
Integration =
0.043251664216828

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

질문:

2025년 3월 6일

댓글:

2025년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by