- 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
7 次查看(过去 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!