29 views (last 30 days)

I have a matrix A which contains values at different angles & radius. The index of this matrix represents ( angles,radius ) as (i,j) . Now how to plot these values on a polar plot ? I also want to make a contour plot for these values in polar co-ordinate .

Let the matrix be test file ( analytical.csv) attached with this document. It contains 5 columns and 4 rows , colums represent different radius = ( 0 , 0.25, 0.50 , 0.75 , 1 ) and rows represent different angles = ( 0 , pi/2 , pi , 3pi/2 ) respectively.

Thanks

KSSV
on 12 Oct 2018

[A,txt,raw] = xlsread('C:\Users\srinivas\Downloads\analytical.csv') ;

r = [ 0 , 0.25, 0.50 , 0.75 , 1] ;

th = [ 0 , pi/2 , pi , 3*pi/2 ] ;

[R,T] = meshgrid(r,th) ;

% Create polar data

% Convert to Cartesian

X = R.*cos(T);

Y = R.*sin(T);

h = polar(X,Y);

hold on;

contourf(X,Y,A);

% Hide the POLAR function data and leave annotations

set(h,'Visible','off')

% Turn off axes and set square aspect ratio

axis off

axis image

Walter Roberson
on 12 Oct 2018

You have chosen to replace Mathwork's plot.m with your own. Because plot() is called in many places in MATLAB, you will need to upgrade your plot.m to handle all of those cases, which will take a lot of work.

What is it that you are extending plot() to be able to handle that it does not handle already ?

Because a partly-completed plot.m is likely to interfere with your use of MATLAB until you have completely finished your fully-compatible extension or replacement of plot(), we would recommend that you name your plot.m by some other name while you work through the development stages.

... We are not sure what any of this has to do with the task of drawing a contour plot of that matrix. Why not use the regular contour() call to do that instead of developing a complete replacement for plot() ?

Image Analyst
on 12 Oct 2018

Walter Roberson
on 12 Oct 2018

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

Start Hunting!
## 5 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621272

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621272

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621273

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621273

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621277

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621277

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621278

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621278

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621683

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/423580-how-to-plot-a-polar-plot-from-a-matrix-or-excel-file#comment_621683

Sign in to comment.