A simple question about undefined function error

Hello,
Before i ask my question i want to mention that i am beginner level in matlab.
I wrote in matlab a simple program which is given below:
function Problem6I(f,g,x)
plot(x,f,'red',x,g,'cyan');
end
I defined x=linspace(0,40000,40), g=sin(x*pi)+(x.^2)/20 and f=(x.^2)/20 , but I still get this error message:
??? Undefined function or method 'Problem6I' for input arguments of type 'double'.
How can I solve it?

 採用された回答

Thomas
Thomas 2012 年 10 月 5 日
編集済み: Thomas 2012 年 10 月 5 日

0 投票

You are defining it as a function Here is more about declaring functions http://www.mathworks.com/help/matlab/ref/function.html
You could save it as problem6l and then run it
If you use it as a script it should work
x=linspace(0,40000,40); g=sin(x*pi)+(x.^2)/20 ; f=(x.^2)/20;
plot(x,f,'red',x,g,'cyan')

2 件のコメント

Antonio
Antonio 2012 年 10 月 5 日
The problem is that my homework consists in defining it as a function that must be able to plot every kind of graph.
Thomas
Thomas 2012 年 10 月 5 日
you need to read about creating functions as described in the link posted about..

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2012 年 10 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by