0% found this document useful (0 votes)
75 views10 pages

Analysis Fixed

This document defines a MATLAB app for analyzing time series data. The app contains tabs for analysis and options. It loads data from a file, calculates time and frequency domain properties, and displays the results in plots and tables. User can select different frequency domain plots and filtering options to view.

Uploaded by

Phong Dang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views10 pages

Analysis Fixed

This document defines a MATLAB app for analyzing time series data. The app contains tabs for analysis and options. It loads data from a file, calculates time and frequency domain properties, and displays the results in plots and tables. User can select different frequency domain plots and filtering options to view.

Uploaded by

Phong Dang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

classdef analysis < [Link].

AppBase

% Properties that correspond to app components


properties (Access = public)
UIFigure [Link]
TabGroup [Link]
AnalysisTab [Link]
dothi [Link]
giatriTable [Link]
giatriTable2 [Link]
ThemButton [Link]
FileEditFieldLabel [Link]
FileEditField [Link]
PhanTichButton [Link]
OptionTab [Link]
UIAxes [Link]
UIAxes2 [Link]
OptionDropDownLabel [Link]
OptionDropDown [Link]
HelpTab [Link]
end

properties (Access = public)


dat
fs
N
fk
t
x
df
X
A
phase
Power
y
env

end

methods (Access = private)


function phantich = func(app)

% fs = [Link];

[Link]= load([Link]);
[Link]= 1/[Link](2,2);
app.N= [Link](end,1);
app.t= [Link](1:app.N,2);
app.x= [Link](1:app.N,3)';
L=app.N+1;

%Frequency Domain
[Link]=[Link] /(app.N-1);
[Link]=0:[Link]:[Link];

app.X=fft(app.x);
app.A=2*abs(app.X)/app.N;

[Link]= angle(app.X);
[Link] = app.A.^2/2;

app.y = hilbert(app.x);
[Link] = abs(app.y);

k=readtable([Link]);
[Link] = k;
xx=table2array(k(1:app.N,2));
yy=table2array(k(1:app.N,3));
plot([Link],xx,yy);

% %Speciality Values
%
% % Means Value
% means= (1/N)*sum(x);
%
% % RMS Value
% RMS = sqrt((1/N)*sum(x.^2));
%
% % Max Value
% xmax= max(x,[],1:N);
%
% %Min Value
% xmin = min(x,[],1:N);
%
% % Peak to Peak Value
% xpeak = xmax - xmin;
%
% %Crest Factor
% Cr=(xpeak)/RMS;
%
% name={'Means'; 'RMS'; 'Max' ; 'Min'; 'Peak'; 'Crest'};
% value={means; RMS; xmax; xmin; xpeak;Cr};
% bb= table(name,value);
% BB= readtable(bb);
% app.UITable2_2.Data= BB;
%

plot(app.t,app.x)
xlim([0 0.74])
plot_param = {'Color', [0.6 0.1 0.2],'Linewidth',0.5};
hold on
plot(app.t,[-1;1]*[Link],plot_param{:})
hold off
xlim([0 0.74])
title('Hilbert Envelope')
xlabel ('Time (s)');
ylabel ('acceleration (m/s^2)');

% figure(),clf
% subplot(3,1,1);
% plot(fk,A);
% xlabel ('Frequency (Hz)');
% xlim ([0 fs/2]);
% title('Amplitude Spectrum');
% subplot(3,1,2);
% plot(fk,phase);
% xlabel ('Frequency (Hz)');
% xlim ([0 fs/2]);
% title('Phase Spectrum ');
% subplot(3,1,3);
% plot(fk,Power);
% xlabel ('Frequency (Hz)');
% xlim ([0 fs/2]);
% title('Power Spectrum');
% if [Link] == ('Bien Do12');
%
% plot([Link],fk,A);
% xlim([Link],[0 fs/2]);
% end
%
% if [Link] == ('Pha123456');
% plot([Link],fk,phase);
% end
%
% if [Link] == ('Cong Suat');
%
% plot([Link],fk,Power);
%
% xlim ([Link],[0 fs/2]);
%
% end
% if [Link] == ('Phổ pha');
%
% plot([Link],fk,phase);
%
% xlim ([Link],[0 fs/2]);
%
% end
% if [Link] == ('Phổ công suất');
%
% plot([Link],fk,Power);
%
% xlim ([Link],[0 fs/2]);
%
% end

% %Low-High-Band Pass Filter


% %LowPassFilter
% xlow = lowpass(x,flow,fs);
% %HighPassFilter
% xhigh = highpass(x,fhigh,fs);
% %BandPassFiler
% xband = bandpass(x,fband,fs);
%
% figure()
%
% subplot(3,1,1);
% plot(fk, xlow);
%
% title('Low Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');
%
% subplot(3,1,2);
% plot(t, xhigh);
%
% title('High Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');
%
% subplot(3,1,3);
% plot(fk, xband);
%
% title('Band Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');

% if [Link] ==1
% figure(),clf;
% xlow = lowpass(x,flow,fs);
% plot(t,xlow)
% title('Low Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');
%
% end
% if [Link] ==1
% figure(),clf;
% xhigh = highpass(x,fhigh,fs);
% plot(t,xhigh)
% title('High Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');
% end
% if [Link] ==1
% figure(),clf;
% xband = bandpass(x,fband,fs);
% plot(t,xband)
% title('Band Pass Filter');
% xlabel('Time (s)');
% ylabel ('Frequence (Hz)');
% end
%
% %Window Function In Fourier Analysis
% %Hamming
% if [Link] ==1
% figure(),clf;
% ham = wvtool(hamming(L));
% end
% %Gaussian
% if [Link] ==1
% figure(),clf;
% gau = wvtool(gausswin(L));
% end
% %Hanning
% if [Link] ==1
% figure(),clf;
% han = wvtool(hann(L));
% end
% %Blackman
% if [Link] ==1
% figure(),clf;
% bla = wvtool(blackman(L));
% end
%
%

end
end

% Callbacks that handle component events


methods (Access = private)

% Value changed function: FileEditField


function FileEditFieldValueChanged(app, event)
value = [Link];

end

% Button pushed function: ThemButton


function ThemButtonPushed(app, event)
[filename, path] = uigetfile('*.txt') ;
[Link] = filename;
figure([Link]);
end

% Button pushed function: PhanTichButton


function PhanTichButtonPushed(app, event)
[Link]();
end
% Value changed function: OptionDropDown
function OptionDropDownValueChanged(app, event)

value = [Link];

if [Link] == ('Bien Do12');

plot([Link],[Link],app.A)
xlim([Link],[0 [Link]/2]);
end

if [Link] == ('Pha123456');

plot([Link],[Link],[Link]);
end

if [Link] == ('Cong Suat');

plot([Link],[Link],[Link]);

xlim ([Link],[0 [Link]/2]);

end
end
end

% Component initialization
methods (Access = private)

% Create UIFigure and components


function createComponents(app)

% Create UIFigure and hide until all components are created


[Link] = uifigure('Visible', 'off');
[Link] = [100 100 873 511];
[Link] = 'UI Figure';

% Create TabGroup
[Link] = uitabgroup([Link]);
[Link] = [1 0 873 512];

% Create AnalysisTab
[Link] = uitab([Link]);
[Link] = 'Analysis';

% Create dothi
[Link] = uiaxes([Link]);
title([Link], '')
xlabel([Link], 'Time(s)')
ylabel([Link], 'Acceleration(m/s^2)')
[Link] = [2.05940594059406 1 1];
[Link] = 'on';
[Link] = 'on';
[Link] = [286 212 549 273];

% Create giatriTable
[Link] = uitable([Link]);
[Link] = {'STT'; 'Name'; 'Value'};
[Link] = {40, 'auto', 'auto'};
[Link] = {};
[Link] = [286 23 264 158];

% Create giatriTable2
app.giatriTable2 = uitable([Link]);
[Link] = {'STT'; 'Time'; 'Value'};
[Link] = {40, 'auto', 'auto'};
[Link] = {};
[Link] = [559 23 278 158];

% Create ThemButton
[Link] = uibutton([Link], 'push');
[Link] = createCallbackFcn(app,
@ThemButtonPushed, true);
[Link] = [171 444 100 22];
[Link] = 'Thêm';

% Create FileEditFieldLabel
[Link] = uilabel([Link]);
[Link] = 'right';
[Link] = [18 444 25 22];
[Link] = 'File';

% Create FileEditField
[Link] = uieditfield([Link], 'text');
[Link] = createCallbackFcn(app,
@FileEditFieldValueChanged, true);
[Link] = [58 444 100 22];

% Create PhanTichButton
[Link] = uibutton([Link], 'push');
[Link] = createCallbackFcn(app,
@PhanTichButtonPushed, true);
[Link] = [86 200 100 22];
[Link] = 'Phân Tích';

% Create OptionTab
[Link] = uitab([Link]);
[Link] = 'Option';

% Create UIAxes
[Link] = uiaxes([Link]);
title([Link], 'Spectrum')
xlabel([Link], 'Frequency(Hz)')
ylabel([Link], '')
[Link] = 'on';
[Link] = 'on';
[Link] = [444 128 428 313];

% Create UIAxes2
app.UIAxes2 = uiaxes([Link]);
title(app.UIAxes2, 'Filter')
xlabel(app.UIAxes2, 'Time(s)')
ylabel(app.UIAxes2, 'Acceleration(m/s^2)')
[Link] = 'on';
[Link] = 'on';
[Link] = [1 128 411 313];

% Create OptionDropDownLabel
[Link] = uilabel([Link]);
[Link] = 'right';
[Link] = 'bold';
[Link] = [444 456 44 22];
[Link] = 'Option';

% Create OptionDropDown
[Link] = uidropdown([Link]);
[Link] = {'Bien Do12', 'Pha123456', 'Cong Suat'};
[Link] = createCallbackFcn(app,
@OptionDropDownValueChanged, true);
[Link] = 'bold';
[Link] = [503 456 100 22];
[Link] = 'Bien Do12';

% Create HelpTab
[Link] = uitab([Link]);
[Link] = 'Help';

% Show the figure after all components are created


[Link] = 'on';
end
end

% App creation and deletion


methods (Access = public)

% Construct app
function app = analysis

% Create UIFigure and components


createComponents(app)

% Register the app with App Designer


registerApp(app, [Link])

if nargout == 0
clear app
end
end

% Code that executes before app deletion


function delete(app)

% Delete UIFigure when app is deleted


delete([Link])
end
end
end

You might also like