I want to fill these 15 equal zones with the different %age value and these values to be depicted by color scale

N = 4; % divides to 4 parts
N1 = 10;
a = linspace(0, 2*pi, N*10);
a1 = linspace(0,2*pi, N1*10);
r1 = 100;
r2=58;
r3=25;
x = r1*cos(a1);
y = r1*sin(a1);
x1 = r2*cos(a1);
y1 = r2*sin(a1);
x2 = r3*cos(a);
y2 = r3*sin(a);
figure(1)
plot(x, y,'k')
hold on
plot([x1(1:10:end);x(1:10:end)], [y1(1:10:end);y(1:10:end)])
hold on
x1 = r2*cos(a);
y1 = r2*sin(a);
plot(x1, y1,'r')
plot([x2(1:10:end); x1(1:10:end)], [y2(1:10:end); y1(1:10:end)])
plot(x2, y2,'b')
hold off
axis equal

Antworten (1)

Use fill(X,Y,C) to fill the polygon having X,Y coordinates, with colour defined by C.

9 Kommentare

thanks Ayush for the reply but I want to fill the experiemental values and then those experiemental values are to be depicted by different colors. For reference I am attaching the profile which I need exactly with my experiemntal values.
Use jmap=jet(n) to create a colormap array.
Use c=colomap(gca,jmap) which sets the colormap for the current figure according to jmap.
Use colorbar to get a color bar beside the figure.
Set the facecolor of polygon using polygon properties.
For reference check out matlab script.
Thank you Ayush
The code you have sent is giving an error: Undefined function or variable 'polyshape'.
Error in ciclecolor (line 20)
outerplot(i+1)=polyshape(x,y);
Wheras I have checked there is no issue with this line. And I also want to know how to give my values for the plot.
Thanks in advance
I have run the file and it's working fine. check the path, disk drive or check for the function file installation.
For values input either use input(prompt) function to get user input data. Or create app with edit box to take input and associate a callback to edit box to change area color in the figure.
Thanks Ayush
The code is working. I am attaching the plot I got from this code but I want to know how it is giving the color in different regions. I also want to know how I can input my experiemntal values. Sorry could not get understand by this "For values input either use input(prompt) function to get user input data. Or create app with edit box to take input and associate a callback to edit box to change area color in the figure". For reference I am attaching the plot I want and the one I am getting from this code.
polyshape function cretaes the polygon.
Use experimental_value(i)=input(["experimental values for polygon " num2str(i)]) for getting user input experimental values for the ith polygon.
Use c=colormap(experimental_value) to get a RGB color array for the experimental value. Make sure you map experimental values to 1-n, i.e. max experimental value maps to n and min experimental value maps to 1, where n is the input given to jet function.
Plotting the polygon creates a polygon object. Use polygon object property FaceColor to assign the color genertated by colormap(experimental_value). Also set the FaceAlpha property of polygon object to 1 to make sure polygon is not transparent.
Repeat this for the number of polygons figure has.
Thanks Ayush for the help
I have tried to insert the values as you have told. But I am not getting the results according to my experiemntal values. I am attaching the code as well as the plot I have obtained. I am also attaching the plot with the values from my experiment and the coloring should be according to these values. Please haver a look at the code and tell me where I am going wrong and how to do it correctly.
Color bar contains the experiemntal values which I have to plot.
Many thanks in advance
Assign the mapped experimental values to the FaceColor property of the polygon object, which will change the polygon color. Additionally change the label of colormap by setting yticklabel using set function.
Use inputdlg(promt) which will create dialogue for user input.
Refer to the attached script.
Thank you Ayush for the help
This is exactly what I needed but there is just one problem. The figure obtained is not symmetric either all of the zones should be divided by equal distance or there should be no gap between the zones as shown in the figure attached.
I am attaching the figure EXACTLY I need and the one I am getting.
Thanks

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 26 Okt. 2020

Kommentiert:

am 6 Nov. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by