error in function with 2 variables
Show older comments
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);
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!