Shading area between two functions

11 次查看(过去 30 天)
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!

采纳的回答

Walter Roberson
Walter Roberson 2023-7-9
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 个评论
Walter Roberson
Walter Roberson 2023-7-10
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Networks 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by