- 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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ece Balkan
am 7 Jul. 2016
Kommentiert: Ece Balkan
am 7 Jul. 2016
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 Kommentare
Akzeptierte Antwort
Stephen23
am 7 Jul. 2016
Bearbeitet: Stephen23
am 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.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!