Filter löschen
Filter löschen

how to use function handle

2 Ansichten (letzte 30 Tage)
googo
googo am 19 Jun. 2013
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?

Antworten (2)

Andrew Newell
Andrew Newell am 19 Jun. 2013
Use ezplot.

Rhys
Rhys am 19 Jun. 2013
Bearbeitet: Rhys am 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 Kommentar
Rhys
Rhys am 25 Jun. 2013
It seems that the function you want to make is the same as fplot.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by