How show the max value in a gaussian function with histfit

조회 수: 7 (최근 30일)
Stefano Vigna
Stefano Vigna 2020년 1월 23일
댓글: Stefano Vigna 2020년 1월 24일
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?

채택된 답변

Stefano Vigna
Stefano Vigna 2020년 1월 24일
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
Stefano Vigna
Stefano Vigna 2020년 1월 24일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by