How can I create a polar plot from 2d matrix

Hi all, I have measured the thickness of the liquid around the pipe at different angles (60 measurement points circumferentially). Therefore I have 60x1 matrix. My question is: how can I draw a polar plot showing the variation of the thickness around the pipe (at 60 points). The pipe diameter is 125 mm and we are only interested in drawing the thickness variations around the wall of the pipe. Any suggestions please? Regards

 採用された回答

Star Strider
Star Strider 2016 年 9 月 21 日

1 投票

I don’t have your data, so I cannot experiment with it. If you have it in angle and radius units, you can use the polar plot function, or to plot it in Cartesian coordinates, the pol2cart function to convert it first.

6 件のコメント

Star Strider
Star Strider 2016 年 9 月 21 日
abu’s ‘Answer’ moved here:
Many thanks Star Strider for your reply. in fact I have only average values as shown below. these 60 points are measured around 150 mm diameter pipe and they are equally spaced. I want to draw a full circule with a diameter of 150 mm first and inside that circule I want to draw a variation of thickness at different angles (i.e. the measured 60 points).
0.033084658 0.293907372 0.653043915 0.618103773 0.703585776 0.777590126 0.825294609 0.528666785 0.688760918 0.872587373 0.657859085 0.717440963 0.805964633 0.725771482 0.587454046 0.566766564 0.961635713 0.847234819 0.811701097 0.776176029 1.08926567 0.949577508 0.825740278 0.873275014 0.888530172 0.849409288 0.673467813 0.77972922 0.81886664 0.808809879 0.816000148 0.931310678 0.615656008 0.576548781 0.446879004 0.438324301 0.640064898 0.601247486 0.551295579 0.516556439 0.589850362 0.956059382 0.822712949 0.761515398 0.7090789 1.193686078 0.88253056 0.9139452 0.641509173 0.562850056 0.440092106 0.573124828 0.607873098 0.642840251 0.611243867 0.551509593 0.505016326 0.594895412 0.603441052 0.477979195
Star Strider
Star Strider 2016 年 9 月 21 日
I would use polar (or polarplot if you have R2016a or later) to do this:
r = [0.033084658
0.293907372
0.653043915
0.618103773
0.703585776
0.777590126
0.825294609
0.528666785
0.688760918
0.872587373
0.657859085
0.717440963
0.805964633
0.725771482
0.587454046
0.566766564
0.961635713
0.847234819
0.811701097
0.776176029
1.08926567
0.949577508
0.825740278
0.873275014
0.888530172
0.849409288
0.673467813
0.77972922
0.81886664
0.808809879
0.816000148
0.931310678
0.615656008
0.576548781
0.446879004
0.438324301
0.640064898
0.601247486
0.551295579
0.516556439
0.589850362
0.956059382
0.822712949
0.761515398
0.7090789
1.193686078
0.88253056
0.9139452
0.641509173
0.562850056
0.440092106
0.573124828
0.607873098
0.642840251
0.611243867
0.551509593
0.505016326
0.594895412
0.603441052
0.477979195];
a = linspace(0, 2*pi, size(r,1))'; % Create Angle Vector
figure(1)
polar(a, r) % Plot Variation Only
figure(2)
polarplot(a, [ones(size(r))*125, r+125]) % Plot Radius & Variation
abu
abu 2016 年 9 月 28 日
Many thanks Star Strider. your answer was really helpful. one more thing, suppose I have film thickness data and its associated angles with time (frame) variations. in other words, I have 3d matrix. is it possible to animate the polar plot with time to see how the film thickness changes with time as animation??
for simplicity, let's say that we have 4x1x5. therefore, we have 5 frame (each frame is separated by 0.02 second) and at each frame we have 4 values of film thickness taken at 0, 90 180 and 270 deg).
The data is given below;
frame 1:
0.293907372
0.653043915
0.618103773
0.703585776
frame 2
0.777590126
0.825294609
0.528666785
0.688760918
frame 3:
0.872587373
0.657859085
0.717440963
0.805964633
frame4:
0.725771482
0.587454046
0.566766564
0.961635713
frame 5:
0.847234819
0.811701097
0.776176029
1.08926567
Star Strider
Star Strider 2016 年 9 月 28 日
My pleasure.
I never tried this with a polar or polarplot function. You would need to use the drawnow and refreshdata functions, paging through the third dimension of your matrix for each plot. (I just used two profiles to illustrate the idea. Make the appropriate changes to the code to plot the full profiles.)
Another option is to plot all your data together in one plot.
Both options:
Frames(:,1) = [0.293907372
0.653043915
0.618103773
0.703585776];
Frames(:,2) = [0.777590126
0.825294609
0.528666785
0.688760918];
a = [0; 90; 180; 270]*pi/180;
figure(1) % Animated Plot
for k1 = 1:size(Frames,2)
polarplot(a, Frames(:,k1)+125)
drawnow
refreshdata
pause(1) % Optional
end
figure(2)
polarplot(a, Frames+125) % All Data Plotted Together
Note: There are very small differences with repsect to a very large radius, so there is not much of a visible change between the sections here.
Star Strider
Star Strider 2016 年 9 月 28 日
abu’s ‘Answer’ moved here:
Thank you. I have tried your code, but I got the following error;
Undefined function or variable 'polarplot'. the version I used is 2015.
any suggestion!
Star Strider
Star Strider 2016 年 9 月 28 日
Yes. Substitute polar for polarplot in figure(1).
Without polarplot, you will not be able to plot all of your vectors in the same call, so the code for figure(2) changes to:
figure(2)
polar(a, Frames(:,1)+125)
hold on
for k1 = 2:size(Frames,2)
polar(a, Frames(:,k1)+125)
end
hold off

サインインしてコメントする。

その他の回答 (1 件)

abu
abu 2016 年 9 月 28 日

0 投票

I used polar function and it works. many thanks

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

タグ

質問済み:

abu
2016 年 9 月 21 日

コメント済み:

2016 年 9 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by