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;

채택된 답변

Angelo Yeo
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)]);
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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by