Not enough input arguments when trying to plot function.

2 次查看(过去 30 天)
I'm trying to plot a function which I created on editor, but am having trouble doing so. This is the function file I created on editor:
function z=f(y);
global B C D Tr c4 Beta gamma
z= (1 + B./y + C./(y.^2) + D./(y.^5) + c4./(Tr.^3*y.^2).*(Beta + gamma./(y.^2)).*exp( gamma./(y.^2)));
end
The values for the variables B, C, D, Tr, c4, Beta, and gamma have already been saved onto my workspace. The function itself works when I type f(y), where y is any number, into the command window. The problem is, every time I try to use the ezplot function to plot a graph of "f", I get an error which states:
Error using f (line 3)
Not enough input arguments.
Can anyone here please help me plot this function?

采纳的回答

Paul
Paul 2014-2-28
编辑:Paul 2014-2-28
ezplot is for expressions with a symbolic variable. You have a function file with a function in it which returns a value for every y you give it. So what you should do is define some values for y you want to use for the plot and get z from f(y). So:
y=1:100; % 1,2,3... 99,100. or 1:0.01:2 --> 1, 1.01, 1.02 .. 1.99, 2
z=f(y);
plot(y,z)
To use ezplot you can do:
%declare constants (B C D etc)
syms y;
z= (1 + B./y + C./(y.^2) + D./(y.^5) + c4./(Tr.^3.*y.^2).*(Beta + gamma./(y.^2)).*exp( gamma./(y.^2)));
ezplot(z)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by