Undefined function 'abs' for input arguments of type 'function_handle'
조회 수: 18 (최근 30일)
이전 댓글 표시
Hi guys! I am getting this error when I try :
warning ('off','all');
beta1=0.2;
alphabar=-0.1;
theta4range=-1:0.1:4;
h4range=0:0.1:1;
c13range=-1:0.1:1;
% c23=-c13;
rmass=1.0;
rmomi= 2.0;
eps=0.01;
hassolution=0;
for theta4=theta4range
for h4=h4range
for c13=c13range
syms x;
H0=@(x) 1/2*(1-beta1.*x);
H14 =@(x)(-h4-theta4.*(x-1./2)+beta1);
H24 =@(x)(h4 + theta4.*(x-1./2));
u13=@(x)1./H0.* -4.* integral(H14,0,x) +c13;
u23=@(x)1./H0.* -4.* integral(H24,0,x) -c13;
p12 = @(x) -3.* integral(u13,0,x);
p22 = @(x) -3.* integral(u23,0,x);
kutta = @(x) 3.* integral(u23 - u13,0,1)+beta1.*alphabar;
lateral = @(x) integral(p22 - p12,0,1)-12.*rmass.*h4;
angular = @(x) integral((x-1./2).*(p22 - p12),0,1)-12.*rmomi.*theta4;
if abs(kutta)<eps & abs(lateral)<eps & abs(angular)<eps
c13
c23
theta4
h4
hassolution=1;
end
end
end
end
if ~hassolution
disp('No solution');
end
댓글 수: 0
답변 (1개)
John D'Errico
2015년 3월 15일
편집: John D'Errico
2015년 3월 15일
It is clearly time for you to learn about functions and how to call them. Start reading the basic tutorials.
Anyway, READ the error message. What is kutta? For that matter, what is lateral? And what is angular?
Answer: They are all function handles. They are NOT numbers. What is the absolute value of a number? That I can do. What is the absolute value of a function handle? Meaningless.
There is a difference between the function handle kutta as you have defined it, and the VALUE of that function on some input like kutta(x), where x is a variable.
By the way, why do you think you need to define the variable x as a symbolic one BEFORE you defined those function handles? There is no need to do so. That line of code was just a waste of CPU cycles.
What I don't know is if you actually want to do symbolic computation on those expressions, or if you want to do numerical computations. If your goal is symbolic computation, then all of those function handles were the wrong thing to do.
댓글 수: 5
Jan
2015년 3월 15일
Warnings are extremely useful when running Matlab. Therefore warning ('off','all') is a very bad idea.
John D'Errico
2015년 3월 15일
Jan makes a superb point. Warnings are there for a good reason. Disabling them is the equivalent to closing your eyes and your ears, and pretending that nothing is wrong. I see nothing. I hear nothing...
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!