Error using piecewise function
이전 댓글 표시
Check for missing argument or incorrect argument data type in call to function 'piecewise'.
Error in D>@(i,j,h)piecewise((i-1)*h==j,1,0) (line 4)
L=@(i,j,h)piecewise((i-1)*h==j,1,0);
Error in D (line 8)
j=j+L(i,x,h)*c(i);
I'm getting this error here,
L=@(i,j,h)piecewise((i-1)*h==j,1,0); %L(i,j,h)=1 when j=(i-1)*h else 0
error is generated when it is called inside other function,
function k=D(x,c,N)
F = @(x)exp(x);
h=1/N;
L=@(i,j,h)piecewise((i-1)*h==j,1,0);
k=F(x);
for i=1:N+1
k=k+L(i,x,h)*c(i);
end
end
댓글 수: 1
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!