Surfc error in plotting
조회 수: 7 (최근 30일)
이전 댓글 표시
I am trying to use surfc to plot 3 variables-time, height, temp. I have imported these variables in from an excel worksheet and have converted them to arrays. When using surfc, I receive an error stating my Z values must have more than one row or column. This is what I have done so far:
temp=table2array(table(:,1)
height=table2array(table(:,2)
time=table2array(table(:,3)
[x,y]=meshgrid(time,height)
z=temp
surfc=(x,y,z)
Any help would be appreciated.
As a side note, I tried to use contour but found an error since my values are not purely in an ascending or descending order. Thanks!
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 1월 4일
Please do not use table as the name of a variable, especially when you are using table objects. Below I will use datatable()
temp = datatable{:,1};
height = datatable{:,2};
time = datatable{:,3};
heightvec = linspace(min(height), max(height));
timevec = linspace(min(time), max(time));
[x, y] = meshgrid(timevec, heightvec);
z = griddata(time, height, temp, x, y);
surf(x, y, z, 'edgecolor', 'none')
댓글 수: 7
Walter Roberson
2018년 1월 5일
Your code extracts time from the third column of your data file. Please check your data file to verify that the time is stored in column 3. It is possible, but it would be unusual: time is usually before the data being me.
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!