Output argument not assigned during call
이전 댓글 표시
I get this error message when I try to run a function that I created. I understand what this is saying, but when I look at my function, the output argument is already correctly defined within the function. So what else could be wrong?
Here is the function:
function y = linInt(xData,yData,x)
if x < xData(1) || x > xData(end)
error('values in x out of range')
else
for i = 1:x
y(i) = yData(i) + ((yData(i+1)-yData(i))*(x-xData(i))/(xData(i+1)-xData(i)));
end
end
end
채택된 답변
추가 답변 (1개)
Alexandra
2013년 4월 3일
You only assign an output value for y, if the else-branch is executed. You also need to assign a value for y for the if-branch. E.G.
if ...
y = [];
else
y = ...;
end
카테고리
도움말 센터 및 File Exchange에서 Debugging and Improving Code에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!