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?
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!