C1 = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1097265/1i.csv')
C1 =
{'Model' } {'MSO4054' }
{'Firmware Version' } {[ 2.1500]}
{'Point Format' } {'Y' }
{'Horizontal Units' } {'S' }
{'Horizontal Scale' } {[ 0.0040]}
{'Sample Interval' } {[ 4.0000e-07]}
{'Record Length' } {[ 100000]}
{'Gating' } {'0.0% to 100.0%'}
{'Probe Attenuation'} {[ 10]}
{'Vertical Units' } {'V' }
{'Vertical Offset' } {[ 0]}
{'Vertical Scale' } {[ 100]}
{'Label' } {'U1' }
{'TIME' } {'CH2' }
{[ -0.0200]} {[ 2.2656]}
{[ -0.0200]} {[ 2.1406]}
L1 = cell2mat(C1(strcmp(C1(:,1),'Record Length'),2));
Ts1 = cell2mat(C1(strcmp(C1(:,1),'Sample Interval'),2));
Lv1 = cellfun(@isnumeric,C1(:,1));
Data1 = cell2mat(C1(Lv1,:));
tv1 = linspace(0, L1-1, L1)*Ts1;
C2 = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1097270/1u.csv')
C2 =
{'Model' } {'MSO4054' }
{'Firmware Version' } {'lut.15' }
{'Point Format' } {'Y' }
{'Horizontal Units' } {'S' }
{'Horizontal Scale' } {[0.004000000000000]}
{'Sample Interval' } {'4,00E-07' }
{'Record Length' } {[ 100000]}
{'Gating' } {'0.0% to 100.0%' }
{'Probe Attenuation' } {[ 1]}
{'Vertical Units' } {'V' }
{'Vertical Offset' } {[ 0]}
{'Vertical Scale' } {[0.002000000000000]}
{'Label' } {1×1 missing }
{'TIME' } {'CH1' }
{[-0.020000000000000]} {[0.001188440000000]}
{[-0.019999600000000]} {[0.001229370000000]}
L2 = cell2mat(C1(strcmp(C2(:,1),'Record Length'),2));
Ts2 = cell2mat(C1(strcmp(C2(:,1),'Sample Interval'),2));
Lv2 = prod(cellfun(@(x)all(isnumeric(x),2),C2),2)>0;
Data2 = cell2mat(C2(Lv2,:));
tv2 = linspace(0, LD2-1, LD2)*Ts2;
plot(Data1(:,1), Data1(:,2))
plot(Data2(:,1), Data2(:,2))
FT_1i = fft(Data1,NFFT1)/L1;
Fv1 = linspace(0, 1, NFFT1/2+1)*Fn1;
FT_1u = fft(Data2,NFFT2)/LD2;
Fv2 = linspace(0, 1, NFFT2/2+1)*Fn2;
[peakamp1,idx1] = max(mag2db(abs(FT_1i(Iv1))*2));
[peakamp2,idx2] = max(mag2db(abs(FT_1u(Iv2))*2));
fprintf(1,'\nMax Amplitude 1i = %.3f dB\nFrequency = %.3f Hz\n',peakamp1,Fv1(idx1))
Max Amplitude 1i = -35.396 dB
Frequency = 19.073 Hz
fprintf(1,'\nMax Amplitude 1u = %.3f dB\nFrequency = %.3f Hz\n\n',peakamp2,Fv2(idx2))
Max Amplitude 1u = -35.391 dB
Frequency = 19.073 Hz
plot(Fv1, mag2db(abs(FT_1i(Iv1))*2))
plot(Fv2, mag2db(abs(FT_1u(Iv2))*2))