How to plot a function of two variables against one variable

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?

답변 (1개)

Star Strider
Star Strider 2018년 10월 6일
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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2018년 10월 6일

답변:

2018년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by