Continuous Convolution using Matlab GUI

Continious Time Convolution with slider Preview

This is semester project for signal and system. Its about continuous time integral convolution.  The project is very simple and not for complex functions but you can add more and more options if you want with a little help.

The project name is based on GUI so there are four panels:

  • About Panel
  • Input Panel
  • Convolved Signal Panel
  • Slider Preview

 

About Panel

About panel is to display name of project and other info about project as mine I displayed my group members in about panel.

   

Input Panel

The second paned is input panel which is used to get input from user to convolve signal. As I said this project will not convolve every signal but you can add more option if you want. For example it has no ability to convolve signal have unit step or u(t).

But it can simple as:

  • Trigonometric functions like: cos(t),Sin(t) or tan(t)
  • Exponetional function: exp(t)      

Now all operations are performed with button in Mfile.

	function pushbutton1_Callback(hObject, eventdata, handles)

This code will be plot x(t) given by user

axes(handles.axes1)
x1 = str2double(get(handles.edit2,'String'))
x2 = str2double(get(handles.edit3,'String'))
t=[x1:0.1:x2];
z1=t %For slider priview time
s=eval(get(handles.edit1,'String'));
plot(t,s),grid
  • axes: tell at where to plot current graph
  • x1: is first limit
  • x2: is second limit
  • S: X(t) function
  • z1: We will use somewhere else
  • t: Time domain for x(t)
  • plot: is use to plot x(t) and grid is use to display gird

Now second input which h(t)

axes(handles.axes2)
h1 = str2double(get(handles.edit5,'String'));
h2 = str2double(get(handles.edit6,'String'));
t=[h1:0.1:h2]
z2=t 
h=eval(get(handles.edit4,'String'));
plot(t,h),grid

Same as above

  • axes: Tells where to plot h(t)
  • h1: is first limit
  • h2: is second limit
  • h: X(t) function
  • z2: We will use somewhere else
  • t: Time domain for x(t)
  • plot: is use to plot h(t) and grid is use to display gird

Convolved Signal Panel

This panel shows output signal.

and here is code to display this graph at axes.

axes(handles.axes3)
t2=x2+h2
t1=x1+h1
t=t1:0.1:t2;
y=conv(s,h)*0.1;
plot(t,y),grid
  • t2: is upper limit
  • t1: is lower limit
  • t: time domain
  • conv: To convolve signal (Matlab function) and multiplied by 0.1 to set amplitude.

Slider Preview Panel

Our 4th panel is about slider. Both signals are shown in axes. Now we can move x(t) with slider and you can see how signal is moving and it will show the status of our x(t) that whether the signal is:

  • No overlap
  • Partial overlap
  • Complete over lap

and the code is:

function slider1_Callback(hObject, eventdata, handles)
slider_value =  get(handles.slider1,'Value');
    x1 = str2double(get(handles.edit2,'String'));
    x2 = str2double(get(handles.edit3,'String'));
    a1=x1;
    a2=x2;
    a1=a1+slider_value
    a2=a2+slider_value
t=[a1:0.1:a2];
z1=t
s=eval(get(handles.edit1,'String'));
h1 = str2double(get(handles.edit5,'String'));
h2 = str2double(get(handles.edit6,'String'));
t=[h1:0.1:h2]
z2=t
h=eval(get(handles.edit4,'String'));
axes(handles.axes5)
plot(z1,s,':',z2,h),legend('x(tau))', 'h(tau)')
set(handles.text1,'String', num2str(a1));
set(handles.text2,'String', num2str(a2));
if (a1< h1 && a2<h1 || a1>h1 && a2>h2)
   set(handles.text123,'String','No ovelaping');
else if (a1< h1 && h1<a2)
   set(handles.text123,'String','Partial Overlaping');
    end
end
   if (h1<a1 && a2<h2)
   set(handles.text123,'String','Complete Overlaping');
   end
   if (a1<h2 && a2>h2)
   set(handles.text123,'String','Partial Overlaping');
   end
guidata(hObject, handles);

The upper coding is not very much good as it should be. For example there is no such need for x1=a1 we can use x1 for next operations and some other things. But you can get idea which the main purpose of this post.

When you will press slider or move slider then x1 will limits will change. At every click there will be increment of "2" this is due to slider Max and Min value which can be found in slider properties. I have set mine -100 to 100 thats why there is increment of 2.

Download
 

Let's Discuss

  • Rod

    i want to plot a graph with the real time clock, and it should be continuous, can you help me with that,