Make a 2D Plot with 3 variables

177 views (last 30 days)
Gekkouga
Gekkouga on 4 Sep 2020
Commented: KSSV on 4 Sep 2020
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 Comments
Arthur Roué
Arthur Roué on 4 Sep 2020
If you want a 2D representation, you can use contour function.

Sign in to comment.

Answers (1)

KSSV
KSSV on 4 Sep 2020
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 Comments
KSSV
KSSV on 4 Sep 2020
Have a look on scatter, scatter3 you can plot with different colors and see the variations.

Sign in to comment.

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by