what is wrong with this code?
Answers (2)
0 votes
1 Comment
Your y2 is numeric, so diff(y2, 2) is requesting the second numeric differences of the numeric array. The resulting numeric array is taken to the power of the numeric variable pr (value 1) and the result is stored in a. Then b is calculated exactly the same way, giving exactly the same result.
So now a is a pure numeric array. And you seem to intend to integrate it with respect to the symbolic variable eta. But there is no routine named int() that accepts numeric first argument.
What you could do is to
int(sym(a), 'eta', 0, 10)
There would be little point in doing that, but it could be done. The integral of a numeric constant with respect to definite bounds is just the constant times the difference between the bounds, so just multiplying a by 10 would achieve the same effect.
8 Comments
The integral of a numeric constant with respect to definite bounds is just the constant times the difference between the bounds. Your sym(((diff([y2],2)).^(pr)) is a vector of numeric constants. Your bounds are 0 and inf. Numeric constant times difference in bounds is numeric constant times (inf-0) which is numeric constant times inf which is inf for all positive constants and -inf for all negative constants, and 0 if the constant is 0.
It happens that your y2 includes negative values and some zeros. Therefore your b1 consists entirely of -inf and 0.
Your q=a1/b1 is a matrix right division operation, roughly equivalent to
q = a1 * pinv(b1)
However the vector of -inf and 0 mixed is calculated as being inconsistent with a1 so you get a warning message displayed about inconsistency. Then after that the symbolic toolbox runs into an internal error in how it deals with the inconsistent system.
It is pretty unlikely that you should be using int() with those numeric constants. I suspect you should be using trapz() to do a numeric integration.
Categories
Find more on Communications Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!