Not enough input arguments when trying to plot function.

1 Ansicht (letzte 30 Tage)
MT
MT am 28 Feb. 2014
Bearbeitet: Paul am 28 Feb. 2014
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?

Akzeptierte Antwort

Paul
Paul am 28 Feb. 2014
Bearbeitet: Paul am 28 Feb. 2014
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)

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics 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!

Translated by