How to Perform a Convolution in MATLAB | MATLAB Tutorial

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024

Комментарии • 14

  • @philparisi_
    @philparisi_  2 года назад

    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

  • @karamvirgill3409
    @karamvirgill3409 3 месяца назад +1

    Can you provide the code?

  • @mahdinemati8573
    @mahdinemati8573 2 года назад +2

    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

    • @philparisi_
      @philparisi_  2 года назад +1

      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!

    • @mahdinemati8573
      @mahdinemati8573 2 года назад +1

      ​@@philparisi_ Thank you for your great Tutorial, it helped me a lot in my university project

    • @philparisi_
      @philparisi_  2 года назад

      Awesome! Thank you for watching and for the updated change to help other viewers! Best of luck with your future programming.

  • @burhanuddinsakarwala5033
    @burhanuddinsakarwala5033 2 года назад +1

    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?

    • @philparisi_
      @philparisi_  2 года назад

      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.

  • @jchopra4423
    @jchopra4423 Год назад +1

    Is there a specific formula you used for the Hamming curve?

    • @philparisi_
      @philparisi_  Год назад

      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!

  • @ronlaspisa450
    @ronlaspisa450 Год назад

    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!

    • @philparisi_
      @philparisi_  Год назад

      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.

  • @knightning3521
    @knightning3521 2 месяца назад

    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')

    • @philparisi_
      @philparisi_  2 месяца назад

      Thank you for providing this!