matias-gonz / mag-analyst

Matlab toolbox to model the magnetization of soft magnetic materials.
Other
4 stars 0 forks source link

Cambiar cómo hacer el splitting de las ramas de la loop #120

Open jsilveyra opened 1 year ago

jsilveyra commented 1 year ago

En lugar que el +/- tip sea para max/min H o M, que sea para la nueva variable que llamé H2M2 (puede llamarse distinto). Me parece que así se manejan mejor curvas que vengan con ruido.

% Split hysteresis loop into ascending and descending branches

% Sort [H,M] so that it begins at Hmin

H2M2 = sign(H).*((H/max(H)).^2 + (M/max(M)).^2); % We create this function to find the tips of the loop [H2M2min, Imin] = min(H2M2); % Find -tip as well as the row index of data in which it appears

Hstart = H(Imin:end); Hend = H(1:Imin); Hsorted = [Hstart Hend];

Mstart = M(Imin:end); Mend = M(1:Imin); Msorted = [Mstart Mend];

H2M2start = H2M2(Imin:end); H2M2end = H2M2(1:Imin); H2M2sorted = [H2M2start H2M2end];

% Find +tip as well as the row index of data in which it appears in the already sorted array
% (when finding Imax for Hmax, for some reason I wasn't finding the curve tip. Need to check with future data.
% So I looked for Mtip. Now, I changed it to H2M2tip.

[H2M2max, Imax] = max(H2M2sorted);

% Split the hysteresis loop into the ascendent and descendent branches, i.e., right and left branches, respectively

Hright = Hsorted(1:Imax); Mright = Msorted(1:Imax);

Hleft = Hsorted(Imax:end); Mleft = Msorted(Imax:end);