How to assign values to a mesh based on xyzc points?

조회 수: 4 (최근 30일)
Philippe Corner
Philippe Corner 2021년 8월 8일
댓글: Philippe Corner 2021년 8월 10일
load('variables.mat')
[xq, yq, zq] = meshgrid(min(x):12.5:max(x),min(y):12.5:max(y),min(z):2:max(z));
cq = nan(size(xq));
[~, pos] = ismember([x,y,z],[xq(:),yq(:),zq(:)],'rows');
cq(pos) = c;
The code creates a mesh grom the x y z data attached. I want to assign a c value to the mesh points that coincide with my original xyzc and left the rest of the points as nan value from "cq".
My indexes from ismember does not work because i havent been able to create a mesh that coincides with all the points from my xyz.
Thanks in advance,
  댓글 수: 3
Philippe Corner
Philippe Corner 2021년 8월 8일
Hi Yazan, thanks for your comment. No I dont want to create a big mesh, I want to try to guarantee that I could get the points from my initial data. Other Idea that I'm getting is to maybe interpolate data to associate a c value to the points of the mesh that I got.
You see that the question is about giving c values to the mesh I create, so the approach may be like using my xyzc information to give a c value to my new xq yq zq points and be sure that outside my xyz, all the cq values are NaN..
Adam Danz
Adam Danz 2021년 8월 9일
The biggest problem is that your data are floating decimals with very high precision. For example,
format long
z(end)
ans =
1.898261677911120e+03
so it's very unlikely that you'll generate perfect matches with a simple grid.
Without knowing the main goal I can't suggest an alternative.

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

답변 (1개)

KSSV
KSSV 2021년 8월 9일
load('variables.mat') ;
nx = length(unique(x)) ;
ny = length(unique(y)) ;
m = 100 ; n = 100 ;
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) ;
C = griddata(x,y,c,X,Y) ;
surf(X,Y,Z,C)
shading interp
colorbar
  댓글 수: 1
Philippe Corner
Philippe Corner 2021년 8월 10일
Mm no, probably I did no express myself correctly. I asked again the same question but with all the data here:
As you can see im proposing to use an interpolation now to solve it, since the positions of the x,y,z dots may be "impossible" to match with a regular grid.
Thanks a lot KSSV

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

카테고리

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