Using countourf for 1D vectors

조회 수: 15 (최근 30일)
Güinther SAIBRO
Güinther SAIBRO 2017년 9월 14일
댓글: Güinther SAIBRO 2017년 9월 19일
Hi.
I have 3 unidimensional vectors like: x=[x1,x2,x3,...]; y=[y1,y2,y3,...] and z=[z1,z2,z3,...]. z is a function of x and y, and I have a pair x/y for each z value z1=f(x1,y1).
If a try to use contourf, I need a matrix and I get a lot of NaN elements, with these NaN I cant't reach a good visualization of my signal.
Would you have some solution to display some level courbes with just the vectors?
Thank you.
  댓글 수: 1
KSSV
KSSV 2017년 9월 15일
Show us the code you have for x,y and z....it can be sorted..

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

답변 (1개)

Akira Agata
Akira Agata 2017년 9월 15일
By using meshgrid and griddata, you can create contour from 3 unidimensional vectors, like:
% 1D data
x = randn(1,400);
y = randn(1,400);
z = x.*exp(-x.^2-y.^2)
% Interpolate for x-y grid
[xq,yq] = meshgrid(-2:.2:2, -2:.2:2);
zq = griddata(x,y,z,xq,yq);
% Visualize the result
figure
contourf(xq,yq,zq);
colorbar;
  댓글 수: 1
Güinther SAIBRO
Güinther SAIBRO 2017년 9월 19일
I got the same problem, a lot of NaN values...

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

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by