Plot a 3D matrix (1 dependent & 2 independent variables)

18 views (last 30 days)
I have a matrix with 2 independent variables (X and y) which have given data. I want to plot this data with X and Y (in the X and Y dimensions) and the corresponding data point in the Z direction so that it appears like a contour map with the independent variables giving the location and the dependent giving the magnitude. Does anyone have an idea how I could do this? Cheers

Accepted Answer

Cris LaPierre
Cris LaPierre on 4 Jan 2021
You could use mesh or surf. As an example, consider X and Y verctors, with Z defined as sin(X) + cos(Y).
X = linspace(0,2*pi,20);
Y = linspace(0,pi,10);
[X,Y] = meshgrid(X,Y);
Z = sin(X) + cos(Y);
Em on 4 Jan 2021
Thank you!! This looks exactly as I hoped.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!