Make a 2D Plot with 3 variables

Hi,
I have an equation for a variable R that is dependent on two variables x and y. I solved the equation and have a list of values for R.
How do I plot R with respect to x and y. I can't find a way to specify x and y axis that correspond to the R values.
Thanks.

3 个评论

How do I plot R with respect to x and y
That sounds as if you have two independent variables and one dependent variable. That would require a 3D plot, unless you wanted to do overlay two different independent variable axes on the same plot (see plotyy() and yyaxis() )
plot3() worked.
I was so silly.
Thanks.
If you want a 2D representation, you can use contour function.

请先登录,再进行评论。

回答(1 个)

Read about contour, countourf, pcolor.
[X,Y,Z] = peaks(100) ;
figure
pcolor(X,Y,Z) ; sjading interp ; colorbar
figure
contour(X,Y,Z)
figure
contourf(X,Y,Z)
% 3d representation
figure
surf(X,Y,Z)
If you don't want to use X, Y use only Z. It will be plotted w.r.t to indices.
[X,Y,Z] = peaks(100) ;
figure
pcolor(Z) ; sjading interp ; colorbar
figure
contour(Z)
figure
contourf(Z)

2 个评论

Hi,
Thanks for the suggestion. But plot3() is what I was expecting for. It worked.
Have a look on scatter, scatter3 you can plot with different colors and see the variations.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

产品

版本

R2020a

标签

提问:

2020-9-4

评论:

2020-9-4

Community Treasure Hunt

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

Start Hunting!

Translated by