Hi I would like to plot 2D beam plot from the Ultrasound data. I want to make it like the reference image I am uploading my code along with data I would appreaciate kind help.
5 次查看(过去 30 天)
显示 更早的评论
% Given data
x_values = [-5 -4 -3 -2 -1 0 1 2 3 4 5];
y_values = [-5 -4 -3 -2 -1 0 1 2 3 4 5];
intensity_x = [0.354894 0.264706 0.518834 0.261813 0.407010 1.034944 0.321868 0.235763 1.162762 0.132057 1.335990];
intensity_y = [0.308505 0.350254 0.517485 1.779078 0.403396 1.083260 0.390343 0.520409 0.527385 0.480424 0.474484];
% Reshape intensity data into matrices for imagesc plot
intensity_x_matrix = reshape(intensity_x, [numel(y_values), numel(x_values)]);
intensity_y_matrix = reshape(intensity_y, [numel(y_values), numel(x_values)]);
% Plotting intensity values
figure;
imagesc(x_values, y_values, intensity_x_matrix + intensity_y_matrix);
xlabel('X Direction (mm)');
ylabel('Y Direction (mm)');
title('Pseudocolor Plot - Intensity X and Y');
colorbar;
colormap('jet');
axis square;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1636136/image.jpeg)
0 个评论
采纳的回答
Angelo Yeo
2024-3-6
The script below to reshape doesn't make sense because the row x col of the target matrix must match the original matrix.
intensity_x_matrix = reshape(intensity_x, [numel(y_values), numel(x_values)]);
intensity_y_matrix = reshape(intensity_y, [numel(y_values), numel(x_values)]);
% Given data
x_values = [-5 -4 -3 -2 -1 0 1 2 3 4 5];
y_values = [-5 -4 -3 -2 -1 0 1 2 3 4 5];
intensity_x = [0.354894 0.264706 0.518834 0.261813 0.407010 1.034944 0.321868 0.235763 1.162762 0.132057 1.335990];
intensity_y = [0.308505 0.350254 0.517485 1.779078 0.403396 1.083260 0.390343 0.520409 0.527385 0.480424 0.474484];
% Reshape intensity data into matrices for imagesc plot
intensity_x_matrix = repmat(intensity_x, numel(y_values), 1);
intensity_y_matrix = repmat(intensity_y', 1, numel(x_values));
% Plotting intensity values
figure;
imagesc(x_values, y_values, intensity_x_matrix + intensity_y_matrix);
xlabel('X Direction (mm)');
ylabel('Y Direction (mm)');
title('Pseudocolor Plot - Intensity X and Y');
colorbar;
colormap('jet');
axis square;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!