MATLAB: Solving Simple Integration Problems

  • Context: MATLAB 
  • Thread starter Thread starter pconn5
  • Start date Start date
  • Tags Tags
    Integration Matlab
Click For Summary
SUMMARY

This discussion addresses the challenges of performing simple integration in MATLAB, specifically when using the symbolic toolbox. Users reported that the command int(x+6,x) yields an unexpected result of (x+6)^2/2 instead of the desired x^2/2 + 6*x. A solution provided involves using a vector to input polynomial coefficients, allowing for elementwise integration. Users are also advised to consider using Mathematica for more robust symbolic computation capabilities.

PREREQUISITES
  • Familiarity with MATLAB syntax and commands
  • Understanding of symbolic mathematics in MATLAB
  • Basic knowledge of polynomial functions and integration
  • Awareness of alternative computational tools like Mathematica
NEXT STEPS
  • Explore MATLAB's symbolic toolbox documentation for advanced integration techniques
  • Learn how to implement polynomial coefficients in MATLAB for integration
  • Investigate Mathematica's capabilities for symbolic computation
  • Research MATLAB's limitations in symbolic mathematics compared to other tools
USEFUL FOR

Students, engineers, and researchers who utilize MATLAB for mathematical computations, particularly those focusing on symbolic integration and polynomial functions.

pconn5
Messages
6
Reaction score
0
I have a question for anyone that is familiar with MATLAB.

I'm trying to do some simple integration in MATLAB (and if your wondering why I don't just do it by hand, it is because I want to implement the same code for a wide variety of functions). The problem is when using int(a) in matlab, it won't integrate a simple linear function such as x+6 with a constant of zero. Instead if I input:

syms x;

int(x+6,x)

The answer is given as (x+6)^2/2, instead of just x^2/2 + 6*x, which almost everything else would do and what I need it to do so I can't set my own integration constants.

Anyone have any help?
 
Physics news on Phys.org
Put the coeffs of your polynomial into a vector. It will to an elementwise integration for you:

>> syms x
>> int([x 6])

ans =

[ x^2/2, 6*x]

Despite 'syms', Matlab was not really designed with symbolic computation in mind. If you can, try Mathematica instead. Maybe they have a demo version?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K