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 日

0 投票

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 Exchange2-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