Hey there! If you're serious about learning MATLAB, I just released a new online MATLAB training with 50+ videos! It has quizzes, tests, a final project, and you receive a certificate at the end! Check it out!!! trainings.internshala.com/matlab-training
your shift is wrong the correct shift is : t1(1) + t2(1) the resone is in Convolution we can swap => f(t)*x(t) = x(t)*f(t) that's why we use : t1(1) + t2(1) thank you for your great Tutorial
Hi Mahdi, thank you for noticing this! In my case, just using t2(1) worked only because t1(1) was simply zero. I will update the description accordingly per your input :) Thank you and have a great week!
HI Burhanuddin, happy to help - however, could you reference a specific time in the video? I do two separate problems in this video and they are not related. The first section of code ends at line 23 and the second section begins at line 36.
At exactly 2:26, your output of conv shows two unusual features - the value at t = 0 is not in the plot, and the max value of the result is 63 instead of 60. After you scale both output and t values, those details are gone, and your final results don't show those. However when I duplicate your code, I get a final graph that has the same two incorrect features. Do you have any idea why the graph at 2:26 is off? Maybe that would help me. Has 'conv' changed since your video? Thanks!
Hi there, I appreciate you exacting comment. Thank you for your patience with my reply. First, let's talk about the x-axis of the plot at 2:26. In my code, line 22, I plot(yt,'k') which only will show the y-values and then x-values are automatically set to the indices. Since MATLAB has no index of zero, the first x-value is 1. Calling that x-axis as 't' is incorrect, which is why I proceed to update this throughout the video. Second, the y-value of 63 is due to a 'too small' of a dt. Keep in mind the plot at 2:26 is purposely bad to show how to correct common mistakes. Think of doing a riemann sum with very large spacing... sometimes you overshoot the correct answer. Plus, at 2:26 I haven't scaled anything either with dt. Throughout the video, I show you how to create a proper set of convolution graphs, my apologies that showing the intermediate steps made things confusing! Lastly, I doubt conv() has changed much (if at all) since this video. MATLAB rarely makes major changes to core functions, and if anything would add a new function such as conv2() or conv3() that would include updated/advanced functionality.
here is working code for the first part. clc, clearvars, close all dt = 0.0001; t1 = 0:dt:2; ft = 2-t1; t2 = -2:dt:2; gt = 3*ones(1,length(t2)); yt = dt*conv(ft,gt); yt_x = (1:length(yt)).*dt + t2(1) + t1(2); figure(1) subplot(2,2,1), plot(t1,ft,'r'),title('f(t) impulse response'), grid on, xlim([-2 2]),xlabel('t'),ylabel('amplitude') subplot(2,2,3), plot(t2,gt,'b'), title('g(t) system input'), grid on, xlabel('t'), ylabel('amplitude'),ylim([0 3.5]) subplot(2,2,[2;4]), plot(yt_x,yt,'k'), title('f(t)*g(t) system response'), grid on, xlabel('t'), ylabel('amplitude')
Hey there! If you're serious about learning MATLAB, I just released a new online MATLAB training with 50+ videos! It has quizzes, tests, a final project, and you receive a certificate at the end! Check it out!!! trainings.internshala.com/matlab-training
Can you provide the code?
your shift is wrong
the correct shift is : t1(1) + t2(1)
the resone is in Convolution we can swap => f(t)*x(t) = x(t)*f(t)
that's why we use : t1(1) + t2(1)
thank you for your great Tutorial
Hi Mahdi, thank you for noticing this! In my case, just using t2(1) worked only because t1(1) was simply zero. I will update the description accordingly per your input :) Thank you and have a great week!
@@philparisi_ Thank you for your great Tutorial, it helped me a lot in my university project
Awesome! Thank you for watching and for the updated change to help other viewers! Best of luck with your future programming.
I could not understand what you had done from line 23 up till line 36, could you please show me what is going on there?
HI Burhanuddin, happy to help - however, could you reference a specific time in the video?
I do two separate problems in this video and they are not related. The first section of code ends at line 23 and the second section begins at line 36.
Is there a specific formula you used for the Hamming curve?
Hi J Chopra, MATLAB has a hamming() function you can use as well www.mathworks.com/help/signal/ref/hamming.html which is pretty straight forward!
At exactly 2:26, your output of conv shows two unusual features - the value at t = 0 is not in the plot, and the max value of the result is 63 instead of 60. After you scale both output and t values, those details are gone, and your final results don't show those. However when I duplicate your code, I get a final graph that has the same two incorrect features. Do you have any idea why the graph at 2:26 is off? Maybe that would help me. Has 'conv' changed since your video? Thanks!
Hi there, I appreciate you exacting comment. Thank you for your patience with my reply.
First, let's talk about the x-axis of the plot at 2:26. In my code, line 22, I plot(yt,'k') which only will show the y-values and then x-values are automatically set to the indices. Since MATLAB has no index of zero, the first x-value is 1. Calling that x-axis as 't' is incorrect, which is why I proceed to update this throughout the video.
Second, the y-value of 63 is due to a 'too small' of a dt. Keep in mind the plot at 2:26 is purposely bad to show how to correct common mistakes. Think of doing a riemann sum with very large spacing... sometimes you overshoot the correct answer. Plus, at 2:26 I haven't scaled anything either with dt. Throughout the video, I show you how to create a proper set of convolution graphs, my apologies that showing the intermediate steps made things confusing!
Lastly, I doubt conv() has changed much (if at all) since this video. MATLAB rarely makes major changes to core functions, and if anything would add a new function such as conv2() or conv3() that would include updated/advanced functionality.
here is working code for the first part.
clc, clearvars, close all
dt = 0.0001;
t1 = 0:dt:2;
ft = 2-t1;
t2 = -2:dt:2;
gt = 3*ones(1,length(t2));
yt = dt*conv(ft,gt);
yt_x = (1:length(yt)).*dt + t2(1) + t1(2);
figure(1)
subplot(2,2,1), plot(t1,ft,'r'),title('f(t) impulse response'),
grid on, xlim([-2 2]),xlabel('t'),ylabel('amplitude')
subplot(2,2,3), plot(t2,gt,'b'), title('g(t) system input'),
grid on, xlabel('t'), ylabel('amplitude'),ylim([0 3.5])
subplot(2,2,[2;4]), plot(yt_x,yt,'k'), title('f(t)*g(t) system response'),
grid on, xlabel('t'), ylabel('amplitude')
Thank you for providing this!