How to rearrange this dataset?
4 views (last 30 days)
Show older comments
Hello,
I would like to make a contour plot (i.e., contourf(x,y,z)), where x is year-day, y is depth, and z is data). However, the shape of my dataset currently looks like:
x y z
21 0 0.1
21 10 0.23
21 20 0.32
22 0 0.31
22 10 0.14
22 20 0.42
23 0 0.23
23 10 0.43
23 20 0.38
I understand that to make a contour plot, z should be looking like this:
0.1 0.31 0.23
0.23 0.14 0.43
0.32 0.42 0.38
How to arrange data like above one? Or is there any other way to make a contour plot with what I have?
Thanks
0 Comments
Accepted Answer
the cyclist
on 11 Dec 2013
There may have been slicker ways to do this further "upstream" in your code, but now you could just do
>> z = reshape(z,3,3);
5 Comments
the cyclist
on 11 Dec 2013
This is difficult to answer in general. You will typically want to use a command like meshgrid() to created the (x,y) framework of grid points, then assign z with the same shape as that output. See
doc meshgrid
for some tips.
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!