- I have generated a matrix Z of data, by looping arrays X and Y in nested for-loops
Contour plot: how to plot matrix Z as the y-axis and array Y as the levels
2 views (last 30 days)
Show older comments
Alessandro Gianolio
on 25 Feb 2020
Commented: Alessandro Gianolio
on 28 Feb 2020
I have generated a matrix Z of data, by looping arrays X and Y in nested for-loops in order to generate solutions for all possible combinations of X and Y. Z is thus indirectly a function of X and Y, but I can't write it as an equation as Z is calculated numerically.
In one particular case I have X being a 1x35065 array, Y a 1x121 array and Z a 35065x121 matrix.
I plotted the contour using
contourf(X, Y, Z')
I now want to generate a second contour plot, by having the Z matrix on the y-axis and the levels denoted by the Y array. I can't figure out how to generate the new Y2 matrix and the Z2 array to plot this (X stays the same). Basically I am looking for the routine to generate Y2 and Z2 from my existing Y and Z data in order to be able to call
contourf(X, Z2, Y2)
0 Comments
Accepted Answer
darova
on 25 Feb 2020
Use meshgrid to create X and Y as matrices
[X1,Y1] = meshgrid(X,Y);
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!