Shading area between two functions

12 vues (au cours des 30 derniers jours)
Jric
Jric le 9 Juil 2023
Commenté : Jric le 11 Juil 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!

Réponse acceptée

Walter Roberson
Walter Roberson le 9 Juil 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 commentaires
Walter Roberson
Walter Roberson le 10 Juil 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 le 11 Juil 2023
Thank you!! Works perfectly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Networks dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by