Lagrange interpolation | Programming Numerical Methods in MATLAB

  Рет қаралды 82,868

mechtutor com

mechtutor com

6 жыл бұрын

The theory and #MATLAB #programming steps of Lagrange's interpolation method are explained with examples in this #tutorial.
Download the FREE MATLAB Cheat Sheet here: mechtutor.thinkific.com/produ...
Get the ebook of this method and many more with code files on this webpage: mechtutor.thinkific.com/cours...
MATLAB Quick Reference - ebook link: mechtutor.thinkific.com/cours...
*** For a full course of Numerical Methods in Python, visit: www.udemy.com/course/programm...
Visit my new Python course webpage: mechtutor.thinkific.com/cours...
Credits:
Intro Music: Title: "Carefree", source:freemusicarchive.org/music/Ke...

Пікірлер: 52
@mechtutorcom
@mechtutorcom 2 күн бұрын
Download the FREE MATLAB Cheat Sheet here: mechtutor.thinkific.com/products/digital_downloads/matlab-cheatsheet
@equiknox_
@equiknox_ 2 ай бұрын
Hey, just wanna let you know that I am thankful I found this video. My prof does not even taught us how to code and he expects us on exam that we code things like this on octave. You are really helpful even years have already passed. Thank you!!
@teerachote
@teerachote 4 жыл бұрын
I just getting into all of this Matlab thing and this video explain it crystal clear, Thank you so much!
@tayneilson
@tayneilson 6 жыл бұрын
wish i found this sooner. i bought your materials keep up the good work
@bastianrojo6175
@bastianrojo6175 5 жыл бұрын
Thank you very much, Mr. It helped me a lot. Greetings from Chile
@alobyerl7635
@alobyerl7635 3 жыл бұрын
Hi! Thank you for the video, I have one more question, how to generate the plot for that equation?
@Sojung0714
@Sojung0714 5 жыл бұрын
that's so simple! Thanks a lot!
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
Awesome video! Thank you! You're very helpful and your voice is very calming and soothing. Thank you!
@shaimashakib6409
@shaimashakib6409 5 жыл бұрын
Thank u so much ! This helped me A LOT :D
@vma011
@vma011 3 жыл бұрын
Thank you so much! You helped me solve a problem of my numerical methods class. Instead of evaluating a single "xp" value, we needed to plot the resulting polynomial as a function, so I had to vectorize the calculation. I generated a vector xp = linspace( min(x), max(x), 200) and initialized the sum and product variables as vectors with dimension 1x200 . I then used exactly your same algorithm but used point-wise product (.*) and division (./) where needed. I solved the thing in few lines thanks to your code!
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
Awesome!
@bcerme16
@bcerme16 5 жыл бұрын
Thank you very much sir! It helped me a lot
@ismailamdah2937
@ismailamdah2937 5 жыл бұрын
Thank you very very much!
@sagarraj4521
@sagarraj4521 4 жыл бұрын
Thanks a lot sir!!!!
@sethmcbrown9492
@sethmcbrown9492 6 жыл бұрын
You're awesome bro
@sylwiawrzesien518
@sylwiawrzesien518 4 жыл бұрын
Hello thank you for your tutorial. Could you tell me how to plot it ?
@ritucreativity3889
@ritucreativity3889 3 жыл бұрын
Thank you so much ❤
@mamtakapoor2600
@mamtakapoor2600 5 жыл бұрын
Very good
@oussamaguerroudj9053
@oussamaguerroudj9053 6 жыл бұрын
thank u ^^
@joelelanga4882
@joelelanga4882 3 жыл бұрын
Thank you very much
@user-ok8wy2vx7b
@user-ok8wy2vx7b 7 ай бұрын
thank you!
@mpixlas4
@mpixlas4 4 жыл бұрын
Great video, thank you very much. I'm trying to figure out how to plot the respective fit... Any thoughts about that?
@mechtutorcom
@mechtutorcom 4 жыл бұрын
Thank you for the comment. The curve can be plotted by adding x array from x0 to xn. The Lagrange interpolation routine should be put inside a for-loop which calculates y-array element corresponding to each x-array element. At the end, two arrays of x and y can be plotted easily with MATLAB plot function. You can find this technique applied at the end of this video of Lagrange interpolation with Python: kzfaq.info/get/bejne/mrp3pLKblrS-p40.html
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
For loops
@DeGameBox_SRBT
@DeGameBox_SRBT 9 ай бұрын
thanks! thanks! thanks! you just saved my studwork! @@mechtutorcom
@gricelbarrera6472
@gricelbarrera6472 Жыл бұрын
thanks!!
@carlospuente3979
@carlospuente3979 2 жыл бұрын
Hey! I have a question: why does pr start at 1? I mean, I know why, but in the code I don't understand why is it there.
@sukranochani5764
@sukranochani5764 3 жыл бұрын
thanks 👍👍👍👍
@bingxinyan8103
@bingxinyan8103 2 жыл бұрын
Great
@agustinacevedo5932
@agustinacevedo5932 5 жыл бұрын
Excellent work but I have a doubt, if I wanted to know the coefficients of the lagrange polynomial, what should I modify the code that you developed? Thank you
@sophia2928
@sophia2928 4 жыл бұрын
i have the same doubt
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
You will need a symbolic Computer Algebra System (CAS) in order to do that since the code only works for numerical evaluations and not symbolic manipulation of variables. If you really want the coefficients of the polynomial, use Vandermonde matrix polynomial to solve the problem. However, be aware that the resulting matrix may be ill-conditioned.
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
You don't have a doubt. You have a question
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
@@sophia2928 you don't have a doubt. You have a question.
@AJ-et3vf
@AJ-et3vf 2 жыл бұрын
@@sophia2928 You will need a symbolic Computer Algebra System (CAS) in order to do that since the code only works for numerical evaluations and not symbolic manipulation of variables. If you really want the coefficients of the polynomial, use Vandermonde matrix polynomial to solve the problem. However, be aware that the resulting matrix may be ill-conditioned.
@vesto6864
@vesto6864 6 ай бұрын
Thanks
@smailkhal
@smailkhal 3 жыл бұрын
Hello, i hope you reply to me. Can we write this program without using *if*? and how to replace *n=length(x)* with *size*
@mechtutorcom
@mechtutorcom 3 жыл бұрын
Hello. Thank you for the comment. Instead of if-statement, you may use a while-loop. But, you will still need a counter for j values. I believe using if-statement, as shown in the video, is much simpler. The size() function is more general than length() because it works with 2, 3 and higher dimensional arrays. In this program, both size() and length() work similarly. The difference is the array return value in size(). For example, [m] = size(x); n = m - 1; I hope I could answer your question.
@mervedenizyldz4226
@mervedenizyldz4226 4 жыл бұрын
Thank you so much for this great explanation. Can you help me with how to obtain the exact polynomial of degree n fitting the data points we have? What should I add to the code you have written in the video? Thanks.
@mechtutorcom
@mechtutorcom 4 жыл бұрын
Thank you Merve for your comment. The degree of polynomial in Lagrange interpolation depends on the number of the given x,y points. If you need to change the degree, you have to increase or decrease the points.
@mervedenizyldz4226
@mervedenizyldz4226 4 жыл бұрын
@@mechtutorcom Thank you so much , I am going to try it.
@user-ik5xm8ci7i
@user-ik5xm8ci7i 3 жыл бұрын
Please, if you are reading this, tell me - why is the " pr " (product variable) equal to one and not any other number?!
@stonedcodingtom9097
@stonedcodingtom9097 2 жыл бұрын
thx
@equiknox_
@equiknox_ 2 ай бұрын
Why is sm = 0??
@MuhammadBilal-bu3wc
@MuhammadBilal-bu3wc 4 жыл бұрын
I have repeated the same code as that of you but my answer doesn't matches. So could you please help me out?
@mechtutorcom
@mechtutorcom 4 жыл бұрын
The code in the video was run on Octave. If you're using MATLAB, some small changes might be needed to have matching results. You can copy and paste your code here, and I will certainly check it.
@alexanderotalvaro6819
@alexanderotalvaro6819 3 жыл бұрын
mister , por que no me arroja resultado , espero su respuesta pa ya , gracias por la atención prestada
@mechtutorcom
@mechtutorcom 3 жыл бұрын
Without seeing your code, it is difficult to know why it does not give results. Is there an error message?
@rabid6767
@rabid6767 4 жыл бұрын
jys n bees
@anujitmaity0722
@anujitmaity0722 2 жыл бұрын
Poor voice
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 56 МЛН
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 29 МЛН
SPILLED CHOCKY MILK PRANK ON BROTHER 😂 #shorts
00:12
Savage Vlogs
Рет қаралды 10 МЛН
Newton Divided Difference Formula & Examples
25:54
Dr. Harish Garg
Рет қаралды 7 М.
Lagrange Interpolation
6:54
Dr. Will Wood
Рет қаралды 136 М.
Interpolation | Lecture 43 | Numerical Methods for Engineers
10:24
Jeffrey Chasnov
Рет қаралды 77 М.
Useful functions for game designers - Lagrange Interpolation
18:01
The Art of Code
Рет қаралды 17 М.
The Basic Newton Method in MATLAB
7:47
Christi Patton Luks
Рет қаралды 85 М.
Lagrange Polynomial Interpolation Introduction | Numerical Methods
5:18
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН