Shading area between two functions

11 ビュー (過去 30 日間)
Jric
Jric 2023 年 7 月 9 日
コメント済み: Jric 2023 年 7 月 11 日
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
Jric
Jric 2023 年 7 月 11 日
Thank you!! Works perfectly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNetworks についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by