How do I create a correct Z matrix from a 'one-value-per-participant' variable for contour plot?
1 view (last 30 days)
Show older comments
Hello, I’m not very familiar with MATLAB and not a good mathematician either. I hope you could help me with contour plots. Let’s say my 3 variables are x=Age (31x1), y=Estimated cranial volume (31x1), and z=Estimated IQ score (31x1). Each variable has only 1 value per participant. When I define my variables and enter the line ‘contour(x,y,z)’, I get a message that my ‘z must be at least 2x2 matrix’. How should I convert my z variable so that it complies to this rule? Thank you.
0 Comments
Answers (1)
Mike Garrity
on 23 Mar 2016
Functions like contour want gridded data, and you have scatter data. You'll need to do a gridding operation to convert your data into the correct form.
I wrote about this recently on the MATLAB Graphics blog, but that just covers a few basic techniques. Gridding data is a pretty rich field, and MATLAB has a lot of tools for doing it.
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!