필터 지우기
필터 지우기

Plotting a surface with scatter data

조회 수: 4 (최근 30일)
Benjamin
Benjamin 2018년 11월 5일
댓글: Walter Roberson 2018년 11월 6일
I have density which is a 310x1 matrix. I have pressure which is a 310x41 matrix. Each column corresponds to a different temperature and each row from 1 to 310 just corresponds to the pressure at a given density in the density matrix.
The temperature is stored in temperature variable as a 1x41 matrix that goes from 100 to 300 in increments of 5 K. How can I plot this data as a surface?
If I try:
surfc(density,temperature,pressure)
I get that the data dimensions must agree.
I have my x-data, density as 310x1.
I have my y-data, temperature as 1x41
Then my z-data, pressure, is 310x41.
Why do the dimensions not agree?
I think I know the issue, but can I just tell MATLAB that x and y values do not change for each matrix? If I manually create every column with all the repetitive data it works. I am not sure if I am being clear here or not, but I imagine the way I am going about doing it is not the most efficient.

채택된 답변

Matt J
Matt J 2018년 11월 5일
[D,T]=meshgrid(density,temperature);
surf(D,T,pressure);
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 11월 6일
Alternately,
surfc(density, temperature, pressure.')
The difference is in the implicit grid ordering. Remember that MATLAB normally treats the first dimension of a 2D array as corresponding to y coordinates.

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

추가 답변 (0개)

카테고리

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