![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1673591/image.png)
how to obtain polar plot (with colorbar) with same dimensions of X Y and Z (i.e. 1XN)?
5 次查看(过去 30 天)
显示 更早的评论
I wish to produce a polar plot with with colorbar
PosCir = (2:1:6);
R = 2:0.25:6.5; % size = 1x19
theta = randi(360,1,19); % size 1x19; non-monotonically varying increase/decrease
Z = rand(1e5,1,19); % size 1x19
now is it possible to make a polar plot with a patch showing color of Z corresponding to eaach theta and R value?
I have used the following function available at: https://in.mathworks.com/matlabcentral/fileexchange/49040-pcolor-in-polar-coordinates
figure
polarPcolor(R,theta,Z,'Ncircles',5,'Nspokes',24,'circlesPos',PosCir); % 2,3,4,5,6
Below, is the ideal example case, but I am dealing with different dimensions of variable. So, it gives error.
%% example case
clear;
PosCir = (2:1:6);
R1 = linspace(2,6.5,19);
theta1 = linspace(0,360,24);
Z1 = linspace(0,10,24)'*linspace(0,10,19);
figure
polarPcolor(R1,theta1,Z1,'Ncircles',5,'Nspokes',24,'circlesPos',PosCir); % 2,3,4,5,6
Any help will be greatly appriciated.
Thanks.
0 个评论
回答(1 个)
Yukthi S
2024-4-19
Hi Megha
I understand that you are getting some errors while trying to use “polarPcolor” in the code. There can be two possibilities for this.
One would be ,since “polarPcolor” is a custom function ,you should ensure that the function file is added to the MATLAB path before running the code.
The second reason can be if you are using MATLAB Online, upload the function file to MATLAB Drive and add it to the path.
I tried the code provided by you at my end and I got the below plot :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1673591/image.png)
Hope this resolves the issue!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!