How to do interpolation in matlab??

4 ビュー (過去 30 日間)
TAPAS
TAPAS 2021 年 2 月 4 日
コメント済み: Star Strider 2021 年 2 月 5 日
I have attached an excel file, which contains x, y, z data. I want to interpolate the data. Can you help?? (In the data for a particular x at different y value, the z value is different. )

採用された回答

Star Strider
Star Strider 2021 年 2 月 4 日
I am not absolutely certain what you want to do.
The row lengths between unique values in the first column are not the same, so using reshape is not an option to create matrices from the data.
One option, if you want to create a uniformly-sampled matrix, is to use griddata to do the interpolation:
D = readmatrix('data.xlsx');
[Du,ia] = unique(D(:,1));
rowlen = diff(ia); % Changes In ‘x’
xv = linspace(min(D(:,1)), max(D(:,1)), 50);
yv = linspace(min(D(:,2)), max(D(:,2)), 50);
[X,Y] = ndgrid(xv,yv);
Z = griddata(D(:,1), D(:,2),D(:,3),X,Y);
figure
surf(X, Y, Z)
This also plots the result.
Change the code appropriately to get the result you want.
  8 件のコメント
TAPAS
TAPAS 2021 年 2 月 5 日
Thank you. The problem I am facing is that I am not getting interpolated data in all the range.
Star Strider
Star Strider 2021 年 2 月 5 日
As always, my pleasure!
I am not certain what to suggest with respect to getting all the information you want from your data, since I am not certain what that is.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by