フィルターのクリア

How to interpolate a set of data wher the X size is different for the Y size

13 ビュー (過去 30 日間)
Robert Jones
Robert Jones 2023 年 1 月 21 日
コメント済み: Robert Jones 2023 年 1 月 22 日
Hello,
I have a set of data X (size=2001,1) and Y (size=3,1). The Z matrix size is (2001,3). X and Y have uniform increments by the X size is not the same as the size of Y.
Can I use meshgrid or interp2? I tried but I got errors
for meshgrid
Error using griddata
The lengths of X and Y must match the size of Z.
for interp2
Error using griddedInterpolant
Sample points vector corresponding to grid dimension 1 must contain 3 elements.
Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 126)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in read_mydata (line 41)
Vq = interp2(theta,phi,co_amp_db,10,22);
Error in read_mydata (line 40)
vq = griddata(theta,phi,co_amp_db,10,22)
=======================================
Here is my code
xlx=input_data_file;
sheetname='MAIN';
addpath(pathToOptimizer)
nrow=2002;
ncol=13;
rangero=[1,1,nrow,ncol];
sheetname='Test';
[NUM,TXT,RAW]=readmycells(xlx,rangero,sheetname);
phi=NUM(1,3:4:ncol)';
theta=NUM(2:nrow,1);
nnp=size(phi);
nnt=size(theta);
np=nnp(2);
nt=nnt(1);
co_amp_db=NUM(2:nrow,2:4:ncol);
co_phase_db=NUM(2:nrow,3:4:ncol);
cx_amp_db=NUM(2:nrow,4:4:ncol);
cx_phase_db=NUM(2:nrow,5:4:ncol);
vq = griddata(theta,phi,co_amp_db,10,22);
Vq = interp2(theta,phi,co_amp_db,10,22);

採用された回答

dpb
dpb 2023 年 1 月 21 日
x=1:10;y=1:3; % coarse spacing
z=rand(numel(x),numel(y));
surf(y,x.',z)
hold on
Z=interp2(y,x.',z,1:0.5:3,[1:0.5:10].'); % increase spacing by half...
surf(1:0.5:3,[1:0.5:10].',Z); % plot on top...
  4 件のコメント
VBBV
VBBV 2023 年 1 月 22 日
移動済み: VBBV 2023 年 1 月 22 日
Check also scatteredInterpolant or griddedInterpolant
Robert Jones
Robert Jones 2023 年 1 月 22 日
Thank you

サインインしてコメントする。

その他の回答 (1 件)

Jonas
Jonas 2023 年 1 月 21 日
you can usw meshgrid to prepare your xq and yq:
Y=9:13;X=1:2:5;Z=rand(5,3);
[xq,yq]=meshgrid(1:0.5:5,9:0.5:13);
interp2(X,Y,Z,xq,yq)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by