Hi Ahmed,
It is my understanding that you have a set of points to plot of a graph, and you have different equations which divide the graph into different regions and you wish to partition the graph based on the equations using various colours. Assuming you know the equations which partition the graph this can be accomplished by the fill function in MATLAB. An example is also given in this answer. To apply different markers in different regions you can use logical indexing and plot separately as explained in this article. This is implemented as follows assuming some 4 dummy functions as regions and one line to be plotted across different regions, Assume the 4 curves and lines to be as follows,
x1 = ones(1,450);
x2 = 1:5;
x3 = -1*ones(1,450);
x4 = 5*ones(1,450);
y1 = 1:450;
y2 = (4*x2).^2 + 50;
y3 = y1;
y4 = y1;
xline = -1:0.1:5;
yline = 200*ones(1,length(xline));
partitions can be made by
x1_f = [x1 fliplr(x3)];
y1_f = [y1 fliplr(y1)];
x2_f = [x1 fliplr(x2)];
y2_f = [y1 fliplr(y2)];
x3_f = [x2 fliplr(x4)];
y3_f = [y2 fliplr(y4)];
plot(x1,y1,'k','LineWidth',2);
hold on
plot(x2,y2,'b','LineWidth',2);
plot(x3,y3,'r','LineWidth',2);
plot(x4,y4,'k','LineWidth',2);
fill(x1_f,y1_f,'g')
fill(x2_f,y2_f,'r')
scatter(xline(xline<1),yline(xline<1),'r*');
scatter(xline(xline>1&xline<3),yline(xline>1&xline<3),'ks')
scatter(xline(xline>3),yline(xline>3),'md')
hold off
Thanks
Kiran
Best Answer