Filter löschen
Filter löschen

How show the max value in a gaussian function with histfit

6 Ansichten (letzte 30 Tage)
Hi, I'm trying to show in the matlab plot the max value for each histfit gaussian function.
I have two gaussian fuction to plot in one graph and I want to show in the plot the max value of the function and on x-axies.
G1(2).max=maxG1
[maxG1, index] = G1max;
x1=x1(index);
I'm not sure about this part of code beacuse the index extrapolation dosn't function.
Could someone explane me how to extract the max value of hostfiit or another way to plot the gaussian fuction by my data in the excel work with an interpolation?

Akzeptierte Antwort

Stefano Vigna
Stefano Vigna am 24 Jan. 2020
G1 = (histfit(x1)); % Funzione istogramma + gaussiana 1, non ha bisogno di plot
delete(G1(1)); % Elimina gli istogrammi 1
get(G1(2)); % DOVREBBE ESTRAPOLARE I VALORI DELLA FUNZIONE G1(2)
a = get(G1(2),'XData'); % ESTRAPOLA I VALORI DI G1(2) SU X
b = get(G1(2),'YData'); % ESTRAPOLA I VALORI DI G1(2) SU Y
G1xmax= mean(a); % Media dei valori contenuti nella matrice a
G1ymax= mean(b); % Media dei valori contenuti nella matrice b
hold on % Tracciare una retta dal punto massimo della gaussiana 1
hr=plot([G1xmax G1xmax],[0 10],'k')
hold on; % Unisce le due gaussiane
G2 = (histfit(x2)); % Funzione istogramma + gaussiana 2
delete(G2(1)); % Elimina gli istogrammi 2
set(G2(2),'color','b');
c = get(G2(2),'XData'); % ESTRAPOLA I VALORI DI G1(2) SU X
d = get(G2(2),'YData'); % ESTRAPOLA I VALORI DI G1(2) SU X
G2xmax= mean(c); % Media dei valori contenuti nella matrice c
G2ymax= mean(d); % Media dei valori contenuti nella matrice d
hold on % Tracciare una retta dal punto massimo della gaussiana 2
hp=plot([G2xmax G2xmax],[0 3.917],'k')
grid on;
xlabel('di/dt[A/ms]');
xticks(-100:50:500) % Settare minimo (-100), massimo (500) e distanza tra un valore e l'altro (50)
ylabel('P');
yticks(0:1:12) % Seettare minimo, massimo e distanza tra un valore e l'altro per y
title('Gaussiane a confronto');
  1 Kommentar
Stefano Vigna
Stefano Vigna am 24 Jan. 2020
I solve my problem by myself like this.
I don't know if this is a nice solution, but it's work for me.
I am here only by myself ahahaha

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by