- fplot(f,...) plots input f for x...
- fplot(xt,yt) plots xt = x(t) and yt = y(t) ....
Not enough input arguments error with fplot
조회 수: 6 (최근 30일)
이전 댓글 표시
This is my plot function, and i would like to plot the data and a function with given time steps, but i get the error attached below.Any help would be appreciated. Thanks!
"Error using PlotFunction>@(t,x)((x(1)*t)/(x(2)+t)) (line 17) Not enough input arguments."
function PlotFunction(x,data)
t = [0.200,0.200,0.222,0.222,0.286,0.286,0.400,0.400,0.667,0.667,2.00,2.00];
figure
plot(t,data,'ro');
title('Measurement data')
xlabel('Time')
ylabel('Measured values')
hold on
for i=1:12
fplot(@(t,x)((x(1)*t)/(x(2)+t)),[t(i) t(i+1)]);
end
hold off
grid on
end
댓글 수: 0
채택된 답변
Stephen23
2016년 7월 7일
편집: Stephen23
2016년 7월 7일
The function that you are providing to fplot is the problem.
You should read the fplot documentation. There it clearly describes what syntaxes and inputs are allowed. Bascially it boils down to these two:
Note that the first is a function of one variable x. The second is two functions of one variable t. You are providing a function of two variables, x and t. This is not supported by fplot.
Those ranges do not make any sense: e.g. for the first loop iteration the range will be t = [0.200,0.200], thus having a width of exactly zero. Why are you trying to plot a graph with width zero ?
Also note that using t for both the vector variable and within the anonymous function is bad coding style: is this is mistake, should they be the same variable, or is there some confusion about how to define an anonymous function to use t ? The code makes it impossible to know. Good code is written with comments, which makes it easier to understand what should be happening.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!