Using FPLOT to plot a multi variable function

Lets say I have function f= (x^3+y^3+z^3). For a constant y and z, I want to plot function 'f' between xmin<x<xmax using fplot. Is this possible?

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Feb. 2014

1 Stimme

f = @(x,y,z) x^3+y^3+z^3;
ycon = 5;
zcon = .34;
fun = @(x) f(x,ycon,zcon);
xmin = -4;
xmax = 6;
fplot(fun, [xmin, xmax])

5 Kommentare

Shima Khatiri
Shima Khatiri am 24 Aug. 2017
What if y and z are not constant? how can we plot the general form?
Walter Roberson
Walter Roberson am 24 Aug. 2017
If x, y, and z are not constant, then you have three input variables and one output variable, and you would need a four-dimensional plot. There are no facilities in MATLAB to do four-dimensional plots.
Your code gives me a plot, but also a warning:
"Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments."
Is there an appropriate way to vectorize this?
f = @(x,y,z) x.^3+y.^3+z.^3;
Thanks, that works. I have a related question about plotting a function given as an integral depending on a parameter, but that seems to deserve it's own post so I'll start a new discussion.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Naveen
Naveen am 6 Feb. 2014

0 Stimmen

Never mind. I found it
fplot(@(x) f(x,yvalue,zvalue), [xmin xmax])
Pratiksha Shinde
Pratiksha Shinde am 7 Aug. 2020

0 Stimmen

How to find FFT of boost converter Boost converter

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-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