Skip to content
Advertisement

TypeError: only size-1 arrays can be converted to Python scalars when using trapz method

This is my python code

JavaScript

And am getting this error:

JavaScript

Why is that so? Integration using quad method worked fine but not with trapz method

Advertisement

Answer

As a user commented, you can only use math functions with scalar values, for arrays you have to use math functions provided in NumPy library.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement