フィルターのクリア

How do I create a colored intensity plot from location and intensity values

54 ビュー (過去 30 日間)
Joshua
Joshua 2023 年 4 月 4 日
コメント済み: Jon 2023 年 4 月 4 日
There are 13 points with an x and y coordinate. Each point has an intensity value from 1-20. I'm wondering how to display a plot with a colored intensity map simillar to a heat map. Any suggestions?

採用された回答

MarKf
MarKf 2023 年 4 月 4 日
Could imagesc work?
sysize = 100; maxintensity = 20; npoints = 13;
coords = randi(sysize,[npoints,2]);
imatc = nan(sysize);
for icx = 1:size(coords,1), imatc(coords(icx,1),coords(icx,2)) = randi(maxintensity,1); end
clims = [1 maxintensity];
imagesc(imatc,clims), xlabel('x'),ylabel('y'), colorbar

その他の回答 (1 件)

Jon
Jon 2023 年 4 月 4 日
This is one approach
% define x,y coordinates and corresponding z value
x = rand(13,1)
y = rand(13,1)
z = x.*y
% make evenly spaced x,y grid to plot data on
[xq,yq]=meshgrid(0:0.1:1,0:0.1:1);
% interpolate data points onto grid
zq = griddata(x,y,z,xq,yq);
% make a filled contour plot (heatmap)
contourf(zq,xq,yq)
  1 件のコメント
Jon
Jon 2023 年 4 月 4 日
The above is just an example to show the approach. Obviously you would assign your actual x,y and z values rather than using random values.

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

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by