MATLAB Answers

googo
0

how to use function handle

googo
さんによって質問されました 2013 年 6 月 19 日
Hello,
I want to write a function code that draw a funcion based on the user input.
function plotFunc(f,x_min,x_max)
f is a function handle.
for example I want to draw x^3 from 1 to -1... how can I defin it in the function?

  0 件のコメント

サインイン to comment.

タグ

2 件の回答

Andrew Newell
Answer by Andrew Newell
on 19 Jun 2013

Use ezplot.

  0 件のコメント

サインイン to comment.


Rhys
Answer by Rhys
on 19 Jun 2013
Edited by Rhys
on 20 Jun 2013

Hi!
to define your function you can use the inline() command and then to plot you can use the fplot() command. Your code may look something like this.
f = inline('x^3') % This creates an inline function
fplot(f, [-1, 1]) % This will plot the inline function f from the limits %set in the second input. Then you can edit the plot area anyway that you %would like (add axis labels and a title)
Hope this helps
Cheers,
Rhys
Edited to make it look nicer.

  1 件のコメント

Rhys
on 25 Jun 2013
It seems that the function you want to make is the same as fplot.

サインイン to comment.



Translated by