I am trying to divide a plot into green and red regions orientated horizallay across the y-axis and at a specific point on an eponential curve. For example, I would like the graph background to be green below a value of 5 on the y-axis of a curve and red above that value. Here is what I have tried so far,
clc
clc
clear
x=1:10;
y=[1 3 5 7 7.2 7.3 7.5 8 8.5 9];
plot(y,x)
%cftool(y,x)
x=0:0.01:10;
a=0.5552;
b=0.3237;
f_x=a*exp(b*x);
plot(x,f_x)
low=0:5; %I would like the plot background to be green in this range
high=5:10; %I would like the plot background to be red in this range
ciplot(low,high,'b');
%function ciplot(lower,upper,x,colour);
% ciplot(lower,upper)
% ciplot(lower,upper,x)
% ciplot(lower,upper,x,colour) % % Plots a shaded region on a graph between specified lower and upper confidence intervals (L and U).
% l and u must be vectors of the same length.
% Uses the 'fill' function, not 'area'. Therefore multiple shaded plots
% can be overlayed without a problem. Make them transparent for total visibility.
% x data can be specified, otherwise plots against index values.
% colour can be specified (eg 'k'). Defaults to blue.
% Raymond Reynolds 24/11/06
%if length(lower)~=length(upper) %error('lower and upper vectors must be same length')
%end
%if nargin<4
%colour='b';
%end
%if nargin<3
% x=1:length(lower);
%end
% convert to row vectors so fliplr can work
%if find(size(x)==(max(size(x))))<2
%x=x'; end
%if find(size(lower)==(max(size(lower))))<2
%lower=lower'; end
%if find(size(upper)==(max(size(upper))))<2
%upper=upper'; end
%fill([x fliplr(x)],[upper fliplr(lower)],colour)
%–Error Message–%
%Error using fill
%String argument is an unknown option.
%Error in ciplot (line 36)
%fill([x fliplr(x)],[upper fliplr(lower)],colour)
%Error in example_yaxis_divide (line 21)
%ciplot(low,high,'b');
Best Answer