How to separately color regions R1, R2, R3, R4 in the 1st quadrant of (delta,theta) plane

3 visualizzazioni (ultimi 30 giorni)
How to separately color regions R1, R2, R3, R4
  • R_1={(δ,θ)│DD>0, δ>0.3414, θ<1.8758}
  • R_2={(δ,θ)│DD=0, δ>0.3414}
  • R_3={(δ,θ) | 0<δ<0.3414}
  • R_4={(δ,θ) | DD<0} ∪ {(δ,θ) | δ≤-0.7} ∪ {(δ,θ) | DD>0, δ>0.3414, δ+0.5θ>1.2793}}
where DD=(delta+.5*theta-1.2793)^2-(4*(1+theta))*(.5*delta-.1707)?
  • DD=0 is the Black curve
  • δ=0.3414 is the Blue line
  • θ=1.8758 is the Red line
  • δ+0.5θ=1.2793 is the Green line
delta=0:0.01:5;
fimplicit(@(delta,theta) (delta+.5*theta-1.2793).^2-(4*(1+theta)).*(0.5*delta-.1707),'Color', 'k', 'linewidth',2);
axis([0 7 0 5])
line([0.3414, 0.3414], [0, 5], 'Color', 'b', 'linewidth',2);
line([0, 7], [1.8758, 1.8758], 'Color', 'r', 'linewidth',2); theta=-2*delta+2.5586;
hold on;
plot(delta,theta,'g', 'LineWidth',2)
xlabel('$\delta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$\theta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
Please color the regions.. I don't know how to color the regions...Please help.

Risposte (1)

Karim
Karim il 20 Dic 2022
Modificato: Karim il 21 Dic 2022
Hi, below i demonstrated how to fill in the region using the patch command.
% evaluate the function to set up the grid points
delta = ((24544953/12500000)/14379)*2500 : 0.01 : 7;
theta_m = 2*delta - 2*sqrt(14379*delta/2500 - 24544953/12500000) + 1193/1000;
theta_p = 2*delta + 2*sqrt(14379*delta/2500 - 24544953/12500000) + 1193/1000;
% combine the data
delta = [fliplr(delta) delta];
theta = [fliplr(theta_p) theta_m];
% create a test plot to see if the function looks ok
figure
plot(delta,theta)
ylim([0 5])
xlim([0 7])
grid on
title('plot function to test the grid')
% set up a patch command to fill in the region
figure
hold on
plot(delta,theta,'Color', 'k', 'linewidth',2);
patch('Faces',1:numel(delta),'Vertices',[delta' theta'],'FaceColor','k','FaceAlpha',0.4)
ylim([0 5])
xlim([0 7])
grid on
xlabel('$\delta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$\theta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
EDIT: added a blue box to demonstrate the concept of the patch region.
Assume we want to color a rectangular region. To define the region we need 4 points:
Grid = [0 5;
0 0;
0.3414 0;
0.3414 5];
Next we need a way to tell the patch command which points (i.e. the rows from the points matrix) he needs to connect. The number of the point is the row from the points matrix (Grid in this example).
Region = [1 2 3 4];
Now we can simply call the patch command to plot the region:
figure
hold on
plot(delta,theta,'Color', 'k', 'linewidth',2);
patch('Faces',Region,'Vertices',Grid,'FaceColor','blue','FaceAlpha',0.75)
ylim([0 5])
xlim([0 7])
grid on
xlabel('$\delta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$\theta\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
  2 Commenti
Atom
Atom il 20 Dic 2022
Thank you.. Would you please color any other area (say the region between blue and black curve) so that I caan fully understand the idea ..please

Accedi per commentare.

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by