Shading area between two functions

61 views (last 30 days)
Jric
Jric on 9 Jul 2023
Commented: Jric on 11 Jul 2023
Hi, I want to shade the area between these two functions but am confused how to use other answers with my code.
My code is as follows:
function [responseDif, slopeDif]=complexityMeasure(myinputfile1, myinputfile2)
load(myinputfile1)
F1=Fsoma;
x1=mean(F1);
load(myinputfile2)
F2=Fsoma;
x2=mean(F2);
responseDif=sum(abs(x1/max(x1)-x2/max(x2)));
slopeDif=sum(abs(diff(x1)/sum(diff(x1))-diff(x2)/sum(diff(x2))));
d1=diff(x1)/sum(diff(x1));
d2=diff(x2)/sum(diff(x2));
figure; semilogx(h,[(x1/max(x1))' (x2/max(x2))']); title 'response functions'
figure;semilogx(h(2:end),[d1' d2']); title 'slopes'
end
and both input files are loaded neurons with information about the soma and firing rate. The figure this output produces looks like:
Thanks so much in advance!

Accepted Answer

Walter Roberson
Walter Roberson on 9 Jul 2023
ymax = max(d1, d2);
ymin = min(d1, d2);
x = h(2:end);
xfill = [x(:); flipud(x(:))];
yfill = [ymax(:); flipud(ymin(:))];
fillcolor = [.5 .5 .5];
hold on
fill(xfill, yfill, fillcolor);
hold off
  3 Comments
Walter Roberson
Walter Roberson on 10 Jul 2023
y1 = x1 ./ max(x1);
y2 = x2 ./ max(x2);
ymax = max(y1, y2);
ymin = min(y1, y2);
x = h;
xfill = [x(:); flipud(x(:))];
yfill = [ymax(:); flipud(ymin(:))];
fillcolor = [.5 .5 .5];
hold on
fill(xfill, yfill, fillcolor);
hold off
Jric
Jric on 11 Jul 2023
Thank you!! Works perfectly.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!