I'm trying to compute a definite integral as follows, but am getting an indexing error. I can run this exact code on my boyfriend's computer, same version of MATLAB, same toolboxes installed, but it works perfectly. I tried 2020a initially and then 2019b as well. Anyone know what could be going on?
syms x
F = int(exp(sin(x)), [0, pi]);
display(F)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must
be symbolic variables, and function body must be sym expression

 채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 13일

0 개 추천

syms x
F = int(exp(sin(x)), [0, pi]);
display(F)
F = 
so you have some other problem happening. For example you might have a variable named exp or sin or int

댓글 수: 3

Ok that makes sense, thanks! I fixed my variable names but now it just returns
F = int(exp(sin(x)), 0, pi)
Why doesn't it return the numerical value?
Walter Roberson
Walter Roberson 2020년 12월 13일
int() is for creating indefinitely precise integrals. When you ask for a pattern matlab does not recognize, or a pattern that matlab recognizes as not having exact solutions, then MATLAB will return the form of the integral. You can use vpa() to approximate. If all you need is the approximation then ude vpaintegral() instead of int()
Mackenzie Dennis
Mackenzie Dennis 2020년 12월 13일
ah thank you!!

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

추가 답변 (0개)

카테고리

제품

릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by