フィルターのクリア

contour map from 3-column matrix?

10 ビュー (過去 30 日間)
LMS
LMS 2016 年 2 月 22 日
コメント済み: LMS 2016 年 2 月 22 日
Hi! I am very new to MATLAB and couldn't find an answer on the forums to a basic question: I need to create a contour plot from 20 points, each with x and y coordinates and elevation z. I created a Matrix B, which has 20 lines and 3 columns. Column 1 is the x coordinates, 2 is the y coordinates, and 3 is the elevation. According to "help contour", I should be able to make a contour plot using
contour(B)
However, the plot I get from this is completely nonsensical. If I split up B so that each column is a vector (x, y, and z), and then use
contour(x,y,z)
I get the error message "Z must be at least a 2x2 matrix".
Could someone please explain to me in very simple terms what I'm doing wrong?
Thank you!
  2 件のコメント
Stephen23
Stephen23 2016 年 2 月 22 日
Please upload your data (in a mat file or text file): edit your question, click the paperclip, click both Choose file and Attach file buttons.
Stephen23
Stephen23 2016 年 2 月 22 日
編集済み: Stephen23 2016 年 2 月 22 日
What you uploaded does not really make any sense compared to your description:
"Column 1 is the x coordinates, 2 is the y coordinates, and 3 is the elevation" seems a bit unlikely. For example if the first column really is the X coordinate, then your data is spaced linearly along the X axis, so you have no 2D data and therefore using contour is totally pointless. It is not clear how this data might represent a 3D surface.

サインインしてコメントする。

採用された回答

Mike Garrity
Mike Garrity 2016 年 2 月 22 日
You've got a list of locations and values. Visualizations like contour are showing what happens between the values. To do that, they need more information than just the locations. They also need some sort of connectivity information. The contour functions are designed for a "quad mesh" (sometimes just called a "grid"). There are also techniques which work on triangle meshes.
So, you need to get your locations and values into some sort of mesh before you can use this sort of visualization technique. We discussed some of your options on this thread about color interpolation. The options are pretty similar for contouring algorithms, so it's probably a good place to start.
  1 件のコメント
LMS
LMS 2016 年 2 月 22 日
Thank you for your helpful and accessible answer. I will try that!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by