- 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
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Stephen23
on 7 Jul 2016
Edited: Stephen23
on 7 Jul 2016
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.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!