function [t, Sig, Tau] = stressgener
%Function [T, SIG, TAU] = STRESSGEN creates the graphical user interface
%to generate the stress courses: normal stress SIG,
%shear stress TAU and time vector T.
%
%Author: Aleksander Karolczuk, 14 August 2009
fh = figure('Name','Stress courses generation. Copyright: a.karolczuk@po.opole.pl',...
'Position',[10,150,730,500],...
'Resize', 'off',...
'Toolbar','none',...
'Menubar','none','Color',[0.941176 0.941176 0.941176]);
panel1 = uipanel('Parent',fh,'Title','Sinusoidal stress signals',...
'Position',[.01 .73 .7 .25]);
panel2 = uipanel('Parent',fh,'Title','Time signal',...
'Position',[.72 .73 .27 .25]);
panel3 = uipanel('Parent',fh,'Title','Slow start',...
'Position',[.85 .456 .14 .25]);
Dtextedit=0.24;
y1=0.5; %first row
y2=0.12; %second row
%--Sig_a and Tau_a-------------------------------------%
edithSiga = uicontrol(panel1,'Style','edit',...
'Units','normalized',...
'String','250',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.33 y1 0.15 Dtextedit]);
texthSiga = uicontrol(panel1,'Style','text',...
'Units','normalized',...
'String','Stress amplitudes, MPa',...
'Position',[0.22 0.8 0.37 0.14]);
edithTaua = uicontrol(panel1,'Style','edit',...
'Units','normalized',...
'String','125',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.33 y2 0.15 Dtextedit]);
%--Equations----------------------------------%
axeshSiga = axes('Parent',panel1,'units','pixels',...
'Position',[7 53 130 26]);
image(imread('stresseq1.jpg','jpg'));
set(gca,'visible','off')
axeshTaua = axes('Parent',panel1,'units','pixels',...
'Position',[9 12 136 26]);
image(imread('stresseq2.jpg','jpg'));
set(gca,'visible','off')
%--Frequencies----------------------------------%
edithfsig = uicontrol(panel1,'Style','edit',...
'Units','normalized',...
'String','20',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.59 y1 0.15 Dtextedit]);
texthfsig = uicontrol(panel1,'Style','text',...
'Units','normalized',...
'String','Frequencies, Hz',...
'Position',[0.57 0.8 0.2 0.14]);
edithftau = uicontrol(panel1,'Style','edit',...
'Units','normalized',...
'String','20',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.59 y2 0.15 Dtextedit]);
%--Phase shift, rad---------------------------------%
edithd = uicontrol(panel1,'Style','edit',...
'Units','normalized',...
'String','0.0',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.81 y2 0.15 Dtextedit]);
texthd = uicontrol(panel1,'Style','text',...
'Units','normalized',...
'String','Phase shift, rad',...
'Position',[0.78 0.4 0.2 0.14]);
%--Time signal---------------------------------%
edithS = uicontrol(panel2,'Style','edit',...
'Units','normalized',...
'String','1000',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.36 y1 0.4 Dtextedit]);
texthS = uicontrol(panel2,'Style','text',...
'Units','normalized',...
'String','Frequency sampling, Hz',...
'Position',[0.01 0.8 0.75 0.14]);
edithL = uicontrol(panel2,'Style','edit',...
'Units','normalized',...
'String','0.2',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.36 y2 0.4 Dtextedit]);
texthL = uicontrol(panel2,'Style','text',...
'Units','normalized',...
'String','Length, s',...
'Position',[0.01 0.4 0.3 0.14]);
%--Main axes-------------------------------------------%
axesh = axes('Parent',fh,'units','normalized',...
'Box','on',...
'Fontsize',8,...
'Position',[0.08 0.09 0.75 0.6]);
set(get(axesh,'xlabel'),'string','Time, s','fontsize',8)
set(get(axesh,'ylabel'),'string','\sigma(t), \tau(t), MPa','fontsize',8)
%---buttons----------------------------------------%
bhSlow = uicontrol(panel3,'Units','normalized',...
'Position',[0.08 0.64 0.84 0.32],...
'String','Slow start',...
'Enable','off',...
'Callback',@buttonSlow);
edithSlow = uicontrol(panel3,'Style','edit',...
'Units','normalized',...
'String','0.20',...
'BackgroundColor','white',...
'Fontsize',9,...
'Position',[0.1 0.1 0.8 Dtextedit]);
texthSlow = uicontrol(panel3,'Style','text',...
'Units','normalized',...
'String','During time, s',...
'Position',[0.05 0.4 0.8 0.14]);
bhApply = uicontrol(fh,'Units','normalized',...
'Position',[0.86 0.18 0.12 0.08],...
'String','Apply',...
'Callback',@buttonApply);
bhOk = uicontrol(fh,'Units','normalized',...
'Position',[0.86 0.08 0.12 0.08],...
'String','OK',...
'Callback',@buttonOK);
uiwait(fh);
%------------------------------------------------%
function buttonApply(hObject,eventdata)
Sig_a=str2double(get(edithSiga,'String'));
Tau_a=str2double(get(edithTaua,'String'));
fsig=str2double(get(edithfsig,'String'));
ftau=str2double(get(edithftau,'String'));
delta=eval(get(edithd,'String'));
fs=str2double(get(edithS,'String'));
T=str2double(get(edithL,'String'));
t=0:1/fs:T;
Sig=Sig_a*sin(2*pi*fsig*t);
Tau=Tau_a*sin(2*pi*ftau*t-delta);
axes(axesh)
plot(t,Sig,'.-k',t,Tau,'.-r')
xlabel('Time, s')
ylabel('\sigma(t), \tau(t), MPa')
legend('\sigma(t)', '\tau(t)')
axis tight
set(bhSlow,'Enable','on')
end
%------------------------------------------------%
function buttonSlow(hObject,eventdata)
T=str2double(get(edithL,'String'));
T0=str2double(get(edithSlow,'String'));
fs=str2double(get(edithS,'String'));
if T0>T,
f = warndlg('Time of slow start cannot be longer than time of stress signals.', 'Warning');
T0 = T;
set(edithSlow,'string',num2str(T0))
uiwait(f)
end
nr=T0*fs;
X=[Sig' Tau'];
w=sin([0:pi/2/nr:pi/2]');
w=w*ones(1,size(X,2));
X(1:size(w,1),:)=w.*X(1:size(w,1),:);
Sig=X(:,1)';
Tau=X(:,2)';
plot(t,Sig,'.-k',t,Tau,'.-r')
xlabel('Time, s')
ylabel('\sigma(t), \tau(t), MPa')
legend('\sigma(t)', '\tau(t)')
axis tight
end
%------------------------------------------------%
function buttonOK(hObject,eventdata)
close(fh)
end
end