Area Normalize EPR Spectra

조회 수: 17 (최근 30일)
Alex Garces
Alex Garces 2023년 1월 24일
댓글: Mathieu NOE 2023년 1월 26일
Hello,
I am relatively new to MATLAB and I am trying to area normalize these 25 spectra. By area normalize, I mean that the absolute value of the area under each individual spectrum is equal to 1. I have seen the previous responses to similar questions and I have attempted to replicate them with my data set.
The issue I am having is that although the original data (before area normalizing) all have similar peak to peak amplitudes, the area normalized data results in extremely variable spectral amplitudes. I realize that the amplitudes of different parts of the spectrum can change when area normalizing, but this kind of variability in the result does not seem plausible.
I included my matlab workspace so that the same data can be used. I also included a figure of the "incorrectly area normalized data".
Any help is greatly appreciated. Thank you in advance!
clc; clear; clf;
Folder = uigetdir; %asks user for folder
Error using matlab.internal.lang.capability.Capability.require
Support for Java user interfaces is required, which is not available on this platform.

Error in uigetdir (line 52)
Capability.require(Capability.Swing);
FilePattern = fullfile(Folder,'*.xml'); %searches folder for .xml files
Files = dir(FilePattern); %puts files into struct array
SortedFiles = natsortfiles(Files);
for K = 1:length(SortedFiles)
thisfilename = fullfile(Folder, SortedFiles(K).name); %file name
[X,Y] = eprload(thisfilename); % extracts data
DataY{K} = num2cell(Y);
TablesY = cell2table(DataY{K}); % puts data into a table
ArrayY = table2array(TablesY);
DataY{K} = real(ArrayY); % takes only the real part of the array
DataX{K} = num2cell(X);
TablesX = cell2table(DataX{K}); % puts data into a table
ArrayX = table2array(TablesX);
DataX{K} = real(ArrayX); % takes only the real part of the array
AreaUnderCurve{K} = abs(trapz(DataY{K})); % absolute value of the total area under the curve
% (I took the absolute value so that it doesn't invert spectra)
AreaNormalized{K} = DataY{K}./AreaUnderCurve{K}; % Divide each Y value by the total area under the curve
AreaCheck = trapz(AreaNormalized{K});
%plot(DataX{K},DataY{K})
plot(DataX{K},AreaNormalized{K})
legend
hold on
end
  댓글 수: 4
Alex Garces
Alex Garces 2023년 1월 25일
편집: Alex Garces 2023년 1월 25일
This worked perfectly! Thank you for the help, it is very much appreciated.
I could be wrong but I don't think I can accept a comment as an answer. If you copy that to an answer I would be more than happy to accept it.
Mathieu NOE
Mathieu NOE 2023년 1월 26일
hello
glad this helped
as you suggested, I moved it in the answer section.
thanks

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

채택된 답변

Mathieu NOE
Mathieu NOE 2023년 1월 25일
이동: Mathieu NOE 2023년 1월 26일
hello
I presume that negative signal area should aslo be counted as positive area
so this line is wrong
AreaUnderCurve{K} = abs(trapz(DataY{K}));
Should be :
AreaUnderCurve{K} = trapz(abs(DataY{K}));
otherwise a perfectly symmetrical sine wave of one period would have area = 0
Also I assume your x spacing is not 1 , then the area computation must also take that in account
area = trapz(X,Y) integrates Y with respect to the coordinates or scalar spacing specified by X.
AreaUnderCurve{K} = trapz(DataX{K},abs(DataY{K}));

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by