# Integrating Expressions in MATLAB: Need Help!

• MATLAB
• p3dro0
In summary, the individual has been struggling to compute the integral of an expression in MATLAB and has tried using the quad and romberg functions with no success. They have been told that the ode23 function may work, but are unsure of how to use it. They have also tested their function for some values and they are correct, but cannot properly integrate it. They are seeking ideas on how to solve this issue.
p3dro0
hell, i have been trying to compute the integral of an expression in matlab, but when it comes to the integration part i can't get the right result. i tried the quad function, and one named romberg i found online. I have been told the ode23 function could work, but i can't figure out how to use it.

I've already created the function in MATLAB and tested it for some values, and they are correct, but when it comes to the integration part i can't get it right.

does anyone have some ideas on what can i do?

thanks

Until and unless you give us the expression, we cannot help you out. We need to know the nature of the error in order to provide a solution.

As a sidenote, quad is obsolete. Use integral instead:
https://in.mathworks.com/help/matlab/ref/integral.html

## 1. How do I integrate an expression in MATLAB?

To integrate an expression in MATLAB, you can use the "int" function. For example, if you want to integrate the expression x^2 from 0 to 5, you would use the following code: int(x^2, 0, 5). This will give you the result of 41.667.

## 2. Can I integrate multiple expressions at once in MATLAB?

Yes, you can integrate multiple expressions at once in MATLAB by using the "int" function with a vector of expressions. For example, if you want to integrate the expressions x, x^2, and x^3 from 0 to 5, you would use the code: int([x, x^2, x^3], 0, 5). This will give you a vector of results for each expression.

## 3. Are there any restrictions on the type of expressions that can be integrated in MATLAB?

Yes, there are some restrictions on the type of expressions that can be integrated in MATLAB. The expression must be a symbolic expression, and it must be continuous on the interval of integration. Also, the integration limits must be real numbers or symbolic variables.

## 4. How can I visualize the result of an integration in MATLAB?

You can visualize the result of an integration in MATLAB by using the "ezplot" function. This function will plot the integrated expression over the specified interval. For example, if you want to plot the expression x^2 from 0 to 5, you would use the code: ezplot(int(x^2, 0, 5)).

## 5. Can I use MATLAB to solve definite integrals with unknown integration limits?

Yes, you can use MATLAB to solve definite integrals with unknown integration limits by using the "int" function with symbolic variables for the limits. For example, if you want to solve the integral of x^2 with unknown limits, you would use the code: int(x^2, a, b). This will give you the result of (1/3)*(b^3-a^3).

Replies
10
Views
2K
Replies
2
Views
1K
Replies
32
Views
3K
Replies
6
Views
2K
Replies
1
Views
3K
Replies
22
Views
3K
Replies
8
Views
2K
Replies
2
Views
3K
Replies
1
Views
1K
Replies
1
Views
1K