How to assign values to a mesh based on xyzc points?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
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
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
参考
カテゴリ
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!