convert 1-d radial profile to a 2-d circular matrix

조회 수: 15 (최근 30일)
Optical_Stress
Optical_Stress 2018년 4월 25일
답변: Karan Singh 2025년 2월 19일
Hi,
I'm struggling to convert a 1-d radial profile to a 2-d circular matrix, my current process yields a rectangular matrix instead. So i guess i'm close, but i'm not sure how to convert the rectangular matrix into a circular one.
v_theta = cd(radiusc{3});
radius_r = radiusc{k};
theta = linspace(0,2*pi(),length(radiusc{k}));
theta_y = sin(v_theta)';
theta_x = cos(v_theta)';
v_y = cd(radiusc{k}).*theta_y; v_x = cd(radiusc{k}).*theta_x;
v_theta = sqrt(v_y.^2+v_x.^2);
imagesc(v_theta);
I get the following image (See attachment).

답변 (1개)

Karan Singh
Karan Singh 2025년 2월 19일
It looks like your approach is generating a rectangular image rather than a circular one because imagesc(v_theta) is treating your matrix as a Cartesian grid rather than a polar one. To correctly convert your 1D radial profile into a 2D circular matrix, you need to interpolate your radial profile onto a polar coordinate grid and then transform it into Cartesian coordinates.
  1. You can use "meshgrid" which creates a 2D representation of your r and theta values. https://in.mathworks.com/help/matlab/ref/meshgrid.html
  2. Then "interp1" function ensures that the radial profile values are properly mapped onto the polar grid. https://www.mathworks.com/help/matlab/ref/double.interp1.html
I have taken some dummy data and wrote some code.
clc; clear; close all;
% Generate synthetic radial profile data
num_points = 100; % Number of radial points
r_max = 50; % Maximum radius
radius_r = linspace(0, r_max, num_points); % Radial positions
v_theta = exp(-radius_r / 20) + 0.1 * rand(1, num_points); % Sample radial profile
% Create a polar grid
theta = linspace(0, 2 * pi, num_points); % Angular positions
[R, Theta] = meshgrid(radius_r, theta); % 2D polar grid
% Convert polar coordinates to Cartesian
X = R .* cos(Theta);
Y = R .* sin(Theta);
% Interpolate the radial profile onto the 2D grid
V = interp1(radius_r, v_theta, R, 'linear', 'extrap');
% Plot the data as an image
figure;
pcolor(X, Y, V); % Ensures circular representation
shading interp;
axis equal; % Keeps it circular
colormap(jet);
colorbar;
title('2D Circular Representation of 1D Radial Profile');
Karan

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by