Error using ==> fprintf Function is not defined for 'sym' inputs

前端 未结 1 1261
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-22 18:54

This is my MATLAB code. The function trapezoidal() is defined separately and it works fine.

syms x;

f = 10 + 2 * x - 6 * (x^2) + 5 * (x^4);

a = 0;
b = 2;

ans_         


        
1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-22 19:30

    The problem is in using the function int

    actual_ans = int(f, 0, 2);
    

    `actual_ans' is still a symbolic variable, even if it is a constant. You can translate it into a numeric variable with

    actual_ans = double(actual_ans);
    

    0 讨论(0)
提交回复
热议问题