How can i bring this equation into matlab?

조회 수: 5 (최근 30일)
KIHOON RYU
KIHOON RYU 2021년 4월 30일
답변: Nipun 2024년 5월 22일
Hi, I want to make a equation solver with matlab.
what i want to make is attatched down below.
here, i have a thousand of data point with alpha and temperature.
also i have A, E, and R value.
here, what i tried is like this.
g_alpha = A/beta*cumtrapz(exp(-E./(R*T(2:length(T),:))));
and
n = 2;
G_alpha = [];
while n < 1000;
g_alpha = A/beta*int(exp(-E./(R*T(n+1,:))),[T(2,:) T(n+1,:)]);
G_alpha = [G_alpha; g_alpha];
n = n + 1;
end
but both of these aren't work well.
do i miss something?
can anyone help me to make this completely?
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 4월 30일
The equation does not appear to involve alpha on the right side, so the integral can be expressed as
T*exp(-E/(R*T)) + (E*ei(-E/(R*T)))/R
provided that E and R are positive.
I am not clear on what the task is? You seem to have a vector of T values but what are you trying to solve?

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

답변 (1개)

Nipun
Nipun 2024년 5월 22일
Hi Kihoon
I understand that you are trying to create a MATLAB solver for the integral equation involving g(α) using provided data points for α and temperature, along with constants A, E, and R.
Here is the correct MATLAB code to compute the integral:
% Given data and constants
alpha = ... % Your data points for alpha
T = ... % Your data points for temperature
A = ... % Given constant A
E = ... % Given constant E
R = ... % Given constant R
beta = ... % Given constant beta
% Number of data points
num_points = length(T);
% Initialize the result array
g_alpha = zeros(num_points, 1);
% Loop to calculate g(alpha) using cumulative trapezoidal integration
for i = 1:num_points
% Define the integrand function
integrand = @(t) exp(-E ./ (R * t));
% Calculate the integral from 0 to T(i)
integral_value = integral(integrand, 0, T(i));
% Calculate g(alpha)
g_alpha(i) = (A / beta) * integral_value;
end
% Display the result
disp(g_alpha);
Make sure to replace the placeholders for alpha, T, A, E, R, and beta with your actual data and constants.
Explanation:
  • The integral function is used to compute the definite integral of the specified integrand function from 0 to 𝑇(𝑖)T(i).
  • The integrand function is defined as an anonymous function @(t) exp(-E ./ (R * t)).
  • The loop iterates over all temperature data points, computes the integral for each, and then calculates 𝑔(𝛼)g(α) for each point.
Refer to the following MathWorks documentation for more information on "integral" function: https://in.mathworks.com/help/matlab/ref/integral.html
Hope this helps.
Regards,
Nipun

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by