"Not enough input arguments" plotting a function

3 ビュー (過去 30 日間)
Sarah
Sarah 2014 年 1 月 11 日
回答済み: manan goel 2019 年 8 月 17 日
(Today is my first day using Matlab.) I've been trying to plot the following function:
function[Rs] = sFn(r)
Rs = 2.*3^(-3./2).*(1-2.*r./3+2.*r^2/27).*exp(-r./3)
end
with
plot(sFn,r) or plot(Rs,r)
The first yields "Not enough input arguments" and the second "Undefined function or variable Rs". I cannot, for the life of me figure out how this is supposed to work. :( Help.

採用された回答

Amit
Amit 2014 年 1 月 12 日
First define r like
r = 1:10;
Then do the plotting using,
plot(r,sFn(r))
  2 件のコメント
Amit
Amit 2014 年 1 月 12 日
Also if this is your first day with Matlab, I'll suggest 'help' commad. That comes in quite handy during the learning process. Like if you having trouble with 'plot' command,
help plot
will give you a quick reference to plot command. Also, the MATLAB documentation is pretty good too.
Happy Coding!
Sarah
Sarah 2014 年 1 月 12 日
Thank you so much! I tried watching tutorials and the help section on plotting, but I didn't realize I needed to write the function as sFn(r).

サインインしてコメントする。

その他の回答 (1 件)

manan goel
manan goel 2019 年 8 月 17 日
x = linspace(-1,1,200);
y = 0.5.*sin.*[sin.*(12.*x)];
plot(x,y)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by