Getting following error while making Contourf plot [ Error using contourf Z must be at least a 2x2 matrix]

조회 수: 8(최근 30일)
I am getting this error while making contour plot [ Error using contourf (Z must be at least a 2x2 matrix]. can someone please help how can i make an contour plot and also i wanted to add z data on it . I am basically looking for following contour plot. can someone please help how can i do it . Thanks in advance
clear all
close all
[num,txt,raw] = xlsread('Book1.xlsx') ;
X = num(:,1) ;
Y = num(:,2) ;
Z = num(:,3) ;

채택된 답변

KSSV 2022년 11월 8일
T = readtable('') ;
x = T.(1) ;
y = T.(2) ;
z = T.(3) ;
m = 50 ; n = 50 ;
xi = linspace(min(x),max(x),m) ;
yi = linspace(min(y),max(y),n) ;
[X,Y] = meshgrid(xi,yi) ;
Z = griddata(x,y,z,X,Y) ;
  댓글 수: 3
KSSV 2022년 11월 9일
You will get the data for the region which is covered by the scattered points. If you want it outisde you need to go for extrapolation; which is not suggested. However you can fix a constant value if you are aware of the data. Read the documentation part with extrapolation option.

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

추가 답변(1개)

KALYAN ACHARJYA 2022년 11월 8일
편집: KALYAN ACHARJYA 2022년 11월 8일
You may be look for other data visulization options, as its a 3 column data e.g
stem3, scatter3 or plot3
In mesh, surface, contour, Z much needed as as matrix (where respective valuses are assigned in grid plane)
  댓글 수: 3

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


Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by