Plotting 3D data

조회 수: 4 (최근 30일)
Adam Rajcan
Adam Rajcan 2021년 2월 22일
댓글: KSSV 2021년 2월 22일
Dear Matlab comunity, I struggle to solve seemingly a simple problem.
I have a 54x3 matrix which I would like to plot, such that first coloumn represents x-axis, second coloumn represents y-axis and third coloumn represents a value assigned to [x,y] points.
However, when I use surf(Error_matrix), what I get is a surface scaled such that x-axis goes from 1 to 3 (as number of coloumns), y-axis goes from 0 to 54 (as number of rows) and z gives some weird combination.
In other words, I have a 6x9 checker board with an value assigned to each intersection (representing an error) and I would like to plot an error value to each of the intersections. Please find the error_matrix attached.
Can you please help me out?

채택된 답변

KSSV
KSSV 2021년 2월 22일
편집: KSSV 2021년 2월 22일
load('Error_matrix.mat')
x = Error_matrix(:,1) ;
y = Error_matrix(:,2) ;
z = Error_matrix(:,3) ;
xi = unique(x) ; nx = length(xi) ;
yi = unique(y) ; ny = length(yi) ;
[X,Y] = meshgrid(xi,yi);
Z= reshape(z,ny,nx) ;
surf(X,Y,Z)
  댓글 수: 2
Adam Rajcan
Adam Rajcan 2021년 2월 22일
Exactly, thank you so much! Could you please also write a short explanation of what went wrong? Or forward me to some tutorial, where I can get to understand the issue?
KSSV
KSSV 2021년 2월 22일
You have a m*3 data.....for this you cannot use surf unless you arrange them into a matrices X, Y and Z.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by