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 vues (au cours des 30 derniers jours)
% 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;

Réponse acceptée

Angelo Yeo
Angelo Yeo le 6 Mar 2024
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)]);
Maybe what you wanted was to repmat?
% 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;

Plus de réponses (0)

Catégories

En savoir plus sur Red dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by