MATLAB: Solving Simple Integration Problems

  • Context: MATLAB 
  • Thread starter Thread starter pconn5
  • Start date Start date
  • Tags Tags
    Integration Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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?