简体   繁体   中英

Function integration on Matlab

I'm trying to re-write a code from Mathematica to Matlab.

The Mathematica original code is:

Mathematica 代码示例

Ok, no problem until here because I can evaluate the TT[x] function wherever I want (x, x+1, ...) and perform the numeric integral.

I want to do exactly the same thing on Matlab and here comes my problem:

TT = simplify(T);
Fx = 7.734*10^(-2)*vpaintegral(TT,x+1,0,Mu)
Result = double(Fx)

Error using sym/vpaintegral (line 131) Cannot integrate with respect to 'x + 1'. The integration variable must be a symbolic variable.

What am I doing wrong? It's possible to evaluate & integrate the function correctly on Mathematica but not on Matlab, is there another way to do it? If I introduce 'x' instead of 'x + 1' the integral works perfectly, as could not have been otherwise.

Thanks in advance!

why don't you replace TT by subs(TT,x,y-1) and then integrate over new symbol y , for example, I am replacing cos(x) in the below function by y and do an integration

syms x y
f=3/4*(1+cos(x))^2
vpaintegral(subs(f,cos(x),y),y,0,1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM