this programme in matlab 2017b but icant run it

2 ビュー (過去 30 日間)
Aalaa Abu alrob
Aalaa Abu alrob 2018 年 8 月 13 日
コメント済み: Walter Roberson 2018 年 8 月 14 日
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
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.
Rik
Rik 2018 年 8 月 13 日
What is the error you are getting? You can run scripts that contain functions since R2016b, so that isn't the problem. I don't have the symbolic toolbox, so I can't check the code itself for you.

サインインしてコメントする。

採用された回答

Tiasa Ghosh
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 件のコメント
Aalaa Abu alrob
Aalaa Abu alrob 2018 年 8 月 14 日
Thanks for your attention .. but my integral is with respect to x.. and other sympoles are constant
Walter Roberson
Walter Roberson 2018 年 8 月 14 日
Your a is not constant, it is an unresolved symbolic variable.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
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.

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by