error in function with 2 variables
古いコメントを表示
I'm making a program that is supposed to take two variables in account. x which is defined by x=linspace(10,170,9) and t. For each value of x there should be a function for which I want to use the integral command. But I somehow seem to get errors and cant figure out the problem. Thanks in advance.
Code: ----------------------------------------------
T=@(t,x)(1/sqrt(1-((sin(x./2)).^2).*(sin(t)).^2))
l=0.1; g=9.82; c=0; d=2.*pi;
x=linspace(10,170,9);
f=zeros(size(x));
for i=1:length(x)
f(i)=integral(@(t)T(t,x(i)),c,d);
end
plot(x,f)
Errors: -----------------------------------------------
Error using /
Matrix dimensions must agree.
Error in @(t,x)(1/sqrt(1-((sin(x./2)).^2).*(sin(t)).^2))
Error in @(t)T(t,x(i))
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
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);
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!