I have a N*N matrix depicting the intensities at different points in a circular plane. They are different intensities on a disc. How to plot the image?

2 Ansichten (letzte 30 Tage)
I have a 10*10 matrix, M depicting the intensities at different points in a disc. The radial vectors of disc is divided as linspace(-1,1 10) and the angle is divided as (0,2*pi,10). Each element in the matrix Mij shows the magnitude for ith radial vector and jth angle. How can we plot the magnitude values in the circular disc space.

Antworten (1)

Matt J
Matt J am 15 Mär. 2025
Bearbeitet: Matt J am 16 Mär. 2025
clc, close all force
N = 10; % Number of polar samples
M = peaks(N); % Example heat map data
T = linspace(0, 2*pi, N)'; % Angular samples
R = linspace(0, 1, N); % Radial samples
[X,Y]=pol2cart(T,R);
figure
pcolor(X, Y, M);
shading interp
colormap(jet)
colorbar
axis equal
title('Polar Heat Map')
  2 Kommentare
David Goodmanson
David Goodmanson am 15 Mär. 2025
Bearbeitet: David Goodmanson am 15 Mär. 2025
Hi Akhil/Matt
The command in the answer should be
[X,Y] = pol2cart(T,R)
The code provides the answer but depending on your data you can make things look smoother with
N = 10; % Number of polar samples
N1 = 180; % 2 degree steps
M = peaks(N); % Example heat map data
theta = linspace(0, 2*pi, N); % Angular samples
r = linspace(0, 1, N); % Radial samples
theta1 = linspace(0, 2*pi, N1); % Angular samples
r1 = linspace(0, 1, N1); % Radial samples
[R, T] = meshgrid(r, theta); % Create polar grid
[R1 T1] = meshgrid(r1,theta1); % Create polar grid
M1 = interp2(R,T,M,R1,T1);
[X1,Y1] = pol2cart(T1,R1)
figure(2)
pcolor(X1, Y1, M1);
shading interp
colormap(jet)
colorbar
axis equal
title('Polar Heat Map')
Matt J
Matt J am 16 Mär. 2025
Or perhaps,
N = 10; % Number of polar samples
M = peaks(N); % Example heat map data
Ms=interp2(M,5); %upsampled/smoothed M
T = linspace(0, 2*pi, width(Ms))'; % Angular samples
R = linspace(0, 1, height(Ms)); % Radial samples
[X,Y]=pol2cart(T,R);
figure
pcolor(X,Y,Ms);
shading interp
colormap(jet)
colorbar
axis equal
title('Polar Heat Map')

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by