필터 지우기
필터 지우기

Undefined function 'Trapzoid' for input arguments of type 'double'.

조회 수: 2 (최근 30일)
Austin
Austin 2015년 2월 6일
답변: Jan 2015년 2월 7일
Hi, i keep getting this error:
Undefined function 'Trapzoid' for input arguments of type 'double'.
below are my codes:
function [output]=Trapzoid(a,b)
logN=1:8
N=zeros(1,8);
A=zeros(1,8);
for j=1:8
N(j)=10^(logN(j));
h=1/N(j);
x=a:h:b;
for i=1:N(j)+1 y(i)=exp(x(i));
end
for i=1:N(j)
A(j)=A(j)+0.5*h*(y(i)+y(i+1));
end
B(j)=log(abs(exp(1)-1-A(j)));
end
whenever i call for function Trapzoid(a,b) for eg, trapzoid(1,8) i will get the error: Undefined function 'Trapzoid' for input arguments of type 'double'. can anyone kindly advise on what actually went wrong? Much Thanks in advance!

채택된 답변

Jan
Jan 2015년 2월 7일
Note:
x = a:h:b;
for i=1:N(j)+1
y(i)=exp(x(i));
end
is less efficient than:
y = exp(a:h:b);

추가 답변 (1개)

Star Strider
Star Strider 2015년 2월 6일
You have to save your ‘Trapezoid’ function in its own file called specifically ‘Trapezoid.m’ in your MATLAB search path. Note that MATLAB is case-sensitive, so calling it as ‘trapezoid(1,8)’ will throw the error. Call it as ‘Trapezoid(1,8)’, and if it is in your MATLAB path, you will not get that error.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by