Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Image plot I am not able to create

1 回表示 (過去 30 日間)
Kushal Kumar
Kushal Kumar 2018 年 11 月 23 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello,
I am not able to create a Image plot of the values. I have the data which represents x , y co-ordinates and corresponding velocity. A simple data file. Please find the attachment.
The image I get when generated is shown in testimg.
But the actual image would be much different, similar to that in Simi_img.
Please help.
Thank you.

回答 (2 件)

GT
GT 2018 年 11 月 23 日
I am using R2018b:
a=readtable('dte2.txt');
plot(a.x_coordinate,a.y_coordinate,'.')
Does this help?

Image Analyst
Image Analyst 2018 年 11 月 23 日
編集済み: Image Analyst 2018 年 11 月 23 日
There are certain (x,y) locations which are not present in your data so those points in the image remain unassigned.
% Import the data.
structData = importdata('dte2.txt')
x = structData.data(:, 1);
y = structData.data(:, 2);
velocity = structData.data(:, 3);
% Determine how many columns there should be in the image.
ux = unique(x);
dx = diff(ux);
subplot(2, 4, 1);
histogram(dx);
grid on;
title('Histogram of x', 'FontSize', 15);
subplot(2, 4, 2);
histogram(dx)
grid on;
title('Histogram of x spacings', 'FontSize', 15);
modeSpacing = mode(dx)
minX = min(x)
maxX = max(x)
numColumns = ceil((maxX - minX) / modeSpacing)
% Determine how many rows there should be in the image.
uy = unique(y);
dy = diff(uy);
subplot(2, 4, 3);
histogram(y)
grid on;
title('Histogram of y', 'FontSize', 15);
subplot(2, 4, 4);
histogram(dy)
grid on;
title('Histogram of y spacings', 'FontSize', 15);
modeSpacing = mode(dy)
minY = min(y)
maxY = max(y)
numRows = ceil((maxY - minY) / modeSpacing)
% Make a blank image.
velocityImage = min(velocity) * ones(numRows, numColumns);
% Turn x and y into rows and columns
xCol = round(mat2gray(x) * (numRows-1)) + 1;
yRow = round(mat2gray(y) * (numColumns-1)) + 1;
% Assign velicities.
for k = 1 : length(x)
velocityImage(yRow(k), xCol(k)) = velocity(k);
end
subplot(2,2,3);
imshow(velocityImage, [], 'XData', ux, 'YData', uy);
axis('on', 'image');
colorbar;
impixelinfo
colormap(jet(256));
% Plot the histogram of values.
subplot(2, 2, 4);
histogram(velocity, 100);
grid on;
xlabel('Velocity', 'FontSize', 15);
ylabel('Count', 'FontSize', 15);
title('Histogram of Velocities', 'FontSize', 15);
See the plot below. Only the blue dots are present in the data.
0001 Screenshot.png
  4 件のコメント
Image Analyst
Image Analyst 2018 年 11 月 24 日
Give it a try. But if you want a solid image, I'd use scatteredInterpolant().
Kushal Kumar
Kushal Kumar 2018 年 11 月 24 日
Hi,
I have tried, ScatteredInterpolant() with nearset alogrithm. However, I am able to get points and variables but not able to access them for the plot.
May I know how can I plot. I think I am going in circles.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by