Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Image plot I am not able to create

1 visualización (últimos 30 días)
Kushal Kumar
Kushal Kumar el 23 de Nov. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (2)

GT
GT el 23 de Nov. de 2018
I am using R2018b:
a=readtable('dte2.txt');
plot(a.x_coordinate,a.y_coordinate,'.')
Does this help?

Image Analyst
Image Analyst el 23 de Nov. de 2018
Editada: Image Analyst el 23 de Nov. de 2018
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 comentarios
Image Analyst
Image Analyst el 24 de Nov. de 2018
Give it a try. But if you want a solid image, I'd use scatteredInterpolant().
Kushal Kumar
Kushal Kumar el 24 de Nov. de 2018
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by