this programme in matlab 2017b but icant run it
2 次查看(过去 30 天)
显示 更早的评论
syms x;
syms E;
syms a;
p(x) =(sqrt(2*(E-potential(x,a))))
q = integral(p(x),0,x)
function [v] = potential(a,x)
v= a.*x
end
2 个评论
Rik
2018-8-13
Today I formatted your code. Next time, you can do it yourself by selecting your code and pushing the {}Code button.
采纳的回答
Tiasa Ghosh
2018-8-13
For using Integral (), you must describe 'p' as a function handle with the '@' notation.Like this:
p = @(x) sqrt(2*(E-potential(x,a)));
This will work for Integral(). However, your second input to integral is 'x' which a symbolic variable. But Integral() accepts only scalar values as input. You need to change that.
3 个评论
更多回答(1 个)
Walter Roberson
2018-8-13
p is defined in terms of the symbolic variable a. integral() is for numeric integration and cannot be used with unresolved symbolic variables.
Please recheck the order of parameters for your function. You define the function with one order but you call it with a different order.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!