%% HET WEERGEVEN VAN DE KRITISCHE STAPFREQUENTIES
%%
% -------------------INITIALISATIE VAN HET PROGRAMMA----------------
function varargout = Stapfrequenties(varargin)
% STAPFREQUENTIES M-file for Stapfrequenties.fig
% STAPFREQUENTIES, by itself, creates a new STAPFREQUENTIES or raises the existing
% singleton*.
%
% H = STAPFREQUENTIES returns the handle to a new STAPFREQUENTIES or the handle to
% the existing singleton*.
%
% STAPFREQUENTIES('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in STAPFREQUENTIES.M with the given input arguments.
%
% STAPFREQUENTIES('Property','Value',...) creates a new STAPFREQUENTIES or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Stapfrequenties_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Stapfrequenties_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Stapfrequenties_OpeningFcn, ...
'gui_OutputFcn', @Stapfrequenties_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% -----------FUNCTIES DIE BIJ DE GUI-COMPONENTEN HOREN--------------
function Stapfrequenties_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Stapfrequenties
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
function varargout = Stapfrequenties_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% -------------------ACHTERGRONDKLEUREN AANPASSEN-------------------
function edit_kx_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_ky_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_lx_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_ly_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_G_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_fsmax_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_fsmin_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% ---------------------------CALLBACKS------------------------------
function pb_fj_Callback(hObject, eventdata, handles)
% Deze functie leest de eigenfrequenties in en vult de lijst met eigenfrequenties in:
[filename, pathname] = uigetfile({'*.txt','All Files (*.*)'});
handles.fj =(load(fullfile(pathname,filename)));
set(handles.cb_fj,'Value',1);
%updates the handles structure
guidata(hObject, handles);
function pb_phij_Callback(hObject, eventdata, handles)
% Deze functie leest de eigenmodes in:
[filename, pathname] = uigetfile({'*.txt','All Files (*.*)'});
handles.phij =(load(fullfile(pathname,filename)))';
set(handles.cb_phij,'Value',1);
%updates the handles structure
guidata(hObject, handles);
function pb_xij_Callback(hObject, eventdata, handles)
% Deze functie leest de dempingsfactor in:
[filename, pathname] = uigetfile({'*.txt','All Files (*.*)'});
handles.xij =(load(fullfile(pathname,filename)));
set(handles.cb_xij,'Value',1);
%updates the handles structure
guidata(hObject, handles);
function pb_grid_Callback(hObject, eventdata, handles)
% Deze functie leest het grid in:
[filename, pathname] = uigetfile({'*.txt','All Files (*.*)'});
handles.grid =(load(fullfile(pathname,filename)));
set(handles.cb_grid,'Value',1);
%updates the handles structure
guidata(hObject, handles);
function edit_kx_Callback(hObject, eventdata, handles)
% Deze functie leest de kx-coördinaat in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Daarna wordt ze opgeslaan in 'handles.k'
input = str2double(get(handles.edit_kx,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
else
handles.kx = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_ky_Callback(hObject, eventdata, handles)
% Deze functie leest de ky-coördinaat in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Daarna wordt ze opgeslaan in 'handles.k'
input = str2double(get(handles.edit_ky,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
else
handles.ky = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_lx_Callback(hObject, eventdata, handles)
% Deze functie leest de lx-coördinaat in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Daarna wordt ze opgeslaan in 'handles.l'
input = str2double(get(handles.edit_lx,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
else
handles.lx = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_ly_Callback(hObject, eventdata, handles)
% Deze functie leest de ly-coördinaat in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Daarna wordt ze opgeslaan in 'handles.l'
input = str2double(get(handles.edit_ly,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
else
handles.ly = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_G_Callback(hObject, eventdata, handles)
% Deze functie leest het gewicht in van de voetganger.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Ook wordt gecontroleerd of de waarde positief is, daarna wordt ze
% opgeslaan in 'handles.G'
input = str2double(get(handles.edit_G,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
elseif (input <= 0)
msgbox('Geef een positief gewicht in','Foutmelding!', 'error');
set(handles.edit_G,'String','');
else
handles.G = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_fsmin_Callback(hObject, eventdata, handles)
% Deze functie leest de min fs waarde in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Ook wordt gecontroleerd of de waarde positief is, daarna wordt ze
% opgeslaan in 'handles.fsmin'
input = str2double(get(handles.edit_fsmin,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
elseif (input <= 0)
msgbox('Geef een positief gewicht in','Foutmelding!', 'error');
set(handles.edit_fsmin,'String','');
else
handles.fsmin = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function edit_fsmax_Callback(hObject, eventdata, handles)
% Deze functie leest de max fs waarde in.
% Eerst wordt er gecontroleerd of er een numerieke waarde ingegeven is.
% Ook wordt gecontroleerd of de waarde positief is, daarna wordt ze
% opgeslaan in 'handles.fsmin'
input = str2double(get(handles.edit_fsmax,'String'));
if isnan(input)
errordlg('Je moet een numerieke waarde ingeven','Bad Input','modal')
uicontrol(hObject)
return
elseif (input <= 0)
msgbox('Geef een positief gewicht in','Foutmelding!', 'error');
set(handles.edit_fsmax,'String','');
else
handles.fsmax = str2double(get(hObject,'String'));
end
%updates the handles structure
guidata(hObject, handles);
function pb_plotapart_Callback(hObject, eventdata, handles)
% Deze functie plot de maximale waarden op een aparte figuur.
copyfig=copyobj(handles.grafiek,figure(1));
set(copyfig, 'Units', 'normalized', 'Position', [.1 .1 .8 .8]);
xlabel('Stapfrequenties [Hz]');
ylabel('Versnelling[m/s²]');
title('Versnelling ten gevolge van de verschillende stapfrequenties voor Young laagfrequent');
function pb_bereken_Callback(hObject, eventdata, handles)
t=0;
% We gaan op zoek naar het dichtsgelegen gridpunt
distances=zeros(length(handles.phij(1,:)),2);
for a=1:length(handles.phij(1,:))
distances(a,1)=sqrt(abs(handles.kx - handles.grid(a,2))^2 + abs(handles.ky - handles.grid(a,3))^2);
distances(a,2)=sqrt(abs(handles.lx - handles.grid(a,2))^2 + abs(handles.ly - handles.grid(a,3))^2);
end
[~,handles.k]=min((distances(:,1)));
[~,handles.l]=min((distances(:,2)));
urms=zeros(1,(handles.fsmax-handles.fsmin)/0.05+1);
u=zeros(1,4);
j=length(handles.fj);
while handles.fj(j)>15
handles.fj(j)=[];
handles.xij(j)=[];
handles.phij(j,:)=[];
j=j-1;
end
for fs=handles.fsmin:0.01:handles.fsmax;
t=t+1;
for h=1:4
fh=h*fs;
switch h
case 1
alpha=min(0.37*(fh-0.95),0.5);
case 2
alpha=0.0044*(fh+12.3);
case 3
alpha=0.005*(fh+5.2);
case 4
alpha=0.0051*(fh+2);
end
Fh=alpha*handles.G;
beta=(fh./handles.fj);
u(h)=sum(abs((-beta.^2.*handles.phij(:,handles.k).*handles.phij(:,handles.l))./((1-beta.^2)+2.*handles.xij.*beta.*i)))*Fh;
end
urms(t)=sqrt(u(1)^2+u(2)^2+u(3)^2+u(4)^2)/sqrt(2);
end
if any(urms)==0
set(handles.txt_message,'String','Opgelet! Het input of outputpunt bevindt zich op de rand van de plaat');
else
set(handles.txt_message,'String','');
end
fs=handles.fsmin:0.01:handles.fsmax;
plot(fs,urms);
xlabel('Stapfrequenties [Hz]');
ylabel('Versnelling[m/s²]');
title('Versnelling ten gevolge van de verschillende stapfrequenties voor Young laagfrequent');
% --------------------------------------------------------------------
function Bestand_Callback(hObject, eventdata, handles)
function Nieuw_Callback(hObject, eventdata, handles)
% Deze functie roept Reset.m aan die het programma afsluit
% en opnieuw opstart.
run(strcat(pwd,'\Reset.m'));