How do I plot three columns of data (x, y, dependent_variable)?

조회 수: 7 (최근 30일)
Gabriel
Gabriel 2015년 2월 26일
댓글: Star Strider 2015년 2월 26일
Hello,
I have three columns of data in a .dat file I imported into Matlab. The first column is the x coordinate value, the second column is the y coordinate value, and the third column is the data point, which is dependent on both the x and y coordinates.
How do I plot the third column of data versus the first two columns (x and y coordinates)?
Thanks very much for any advice.

답변 (3개)

Titus Edelhofer
Titus Edelhofer 2015년 2월 26일
Hi,
in your case usually a 3D view is the natural one. Alternatives would be to show the third column as the color (using scatter), something like
scatter(x, y, 10, z)
Or use contour, if isolines make sense for your data.
Titus

Star Strider
Star Strider 2015년 2월 26일
편집: Star Strider 2015년 2월 26일
Three options, depending on what you want: stem3, scatter3 or plot3 functions. (I prefer stem3 because it locates the position of the z data with respect to x and y.)
  댓글 수: 2
Star Strider
Star Strider 2015년 2월 26일
Gabriel’s ‘Answer’ moved here...
Thanks Star Strider.
All of the above commands still give me 3D views of the data. I'm looking for a 2D representation of the data.
Any ideas?
Star Strider
Star Strider 2015년 2월 26일
You didn’t say that in your initial Question.
I agree with Titus. With the 2D constraint, I can’t think of anything better.
Otherwise:
figure(1)
subplot(2,1,1)
plot(x, z)
subplot(2,1,2)
plot(y, z)

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2015년 2월 26일
If you want to view 3d data (spatial, spatial, value) in two d, you could use color in scatter to represent z and x/y for x/y.
>> scatter(1:10,rand(1,10),50,rand(1,10),'*')

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by