How to plot a function of two variables against one variable
Mostrar comentarios más antiguos
I have a function z(x,y). I have set up an array for x and I need y=x^2. I've done that and set up the function but I cannot figure out how I am supposed to plot z against x. fplot doesn't work because I have more than one variable. What command should I use?
Respuestas (1)
Star Strider
el 6 de Oct. de 2018
I am not certain what you want.
The documentation on the plot (link) function is an appropriate place to start. That page, and the links in it and at the end of it will eventually lead you to the correct approach. Then, when in doubt, experiment.
Explore these:
x = 1:10; % Create Data
y = x.^2; % Create Data
[X,Y] = meshgrid(x,y);
z = @(x,y) sin(x*2*pi/max(x(:))) .* cos(y*2*pi/max(y(:))); % Create Function
figure
surf(x, y, z(X,Y))
grid on
figure
plot(x, z(X,Y))
grid
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!