Input function must return 'double' or 'single' values. Found 'sym'.

142 ビュー (過去 30 日間)
shahin hashemi
shahin hashemi 2020 年 4 月 7 日
コメント済み: Ameer Hamza 2020 年 4 月 8 日
dear all
when i using integral command although i define z i get the following error
clc
clear all
E2=10;
E1=20;
lE=E2/E1;
n=1;
h=2;
v1=30;
v2=40;
lv=v2/v1;
sym z
Eb=1+(((2*z+h)/2*h)^n)*(lE-1)
vb=1+(((2*z+h)/2*h)^n)*(lv-1)
fun=@(z) Eb/((1-(v1^2)*(vb^2))*h)
A11=integral(fun,-1/2,1/2)
and the error :
Undefined function or variable 'z'.
Error in first (line 13)
Eb=1+(((2*z+h)/2*h)^n)*(lE-1)
and also when i use syms z instead of sym z i get the following one :
fun =
function_handle with value:
@(z)Eb/((1-(v1^2)*(vb^2))*h)
Error using integralCalc/finalInputChecks (line 511)
Input function must return 'double' or 'single' values. Found 'sym'.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in first (line 18)
A11=integral(fun,-1/2,1/2)
i really appreciated if someone could help me with this

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 8 日
Correct syntax is to use 'syms', not 'sym'. Also you should use matlabFunction to convert symbolic equation to numeric
clc
clear all
E2=10;
E1=20;
lE=E2/E1;
n=1;
h=2;
v1=30;
v2=40;
lv=v2/v1;
syms z
Eb=1+(((2*z+h)/2*h)^n)*(lE-1)
vb=1+(((2*z+h)/2*h)^n)*(lv-1)
fun= matlabFunction(Eb/((1-(v1^2)*(vb^2))*h))
A11=integral(fun,-1/2,1/2)
  12 件のコメント
shahin hashemi
shahin hashemi 2020 年 4 月 8 日
wow you are my hero :D tanx
Ameer Hamza
Ameer Hamza 2020 年 4 月 8 日
Glad to be of help :D

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by