How to do interpolation in matlab??
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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
2021 年 2 月 4 日
Can i make it an 2d interpretation instead of 3d??
TAPAS
2021 年 2 月 4 日
Means I want to represent it in a plane not as a 3d surface
TAPAS
2021 年 2 月 4 日
Something like this image.
Star Strider
2021 年 2 月 4 日
It was not initially obvious what result you wanted.
It is straightforward to change the resolution of the interpolation:
N = 250;
xv = linspace(min(D(:,1)), max(D(:,1)), N);
yv = linspace(min(D(:,2)), max(D(:,2)), N);
[X,Y] = ndgrid(xv,yv);
Z = griddata(D(:,1), D(:,2),D(:,3),X,Y);
With respect to plotting, one option:
figure
surf(X, Y, Z)
shading('interp')
view(0,90)
contourf(X, Y, Z, 'EdgeColor','none')
Experiment to get the result you want.
TAPAS
2021 年 2 月 5 日
can i do kriging interpolation??
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
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 件)
カテゴリ
ヘルプ センター および File Exchange で Multirate Signal Processing についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
