HELP!! Seriously struggling with my final MATLAB assignment! I've been doing it for over 6 hours now and I'm ridiculously stuck :( if anyone could help at all I would REALLY appreciate it :( THANK YOUUU
Mostrar comentarios más antiguos
Attached is my code and assignment. I haven't included cos(x) yet because I can't figure out sin(x). My code is pretty pathetic!! I understand everything we've done up to loops but this is killing me .. If anyone has any input at all I'd really appreciate it!! Thank you :)
2 comentarios
Star Strider
el 19 de Mzo. de 2015
Take a deep breath and relax!
I haven’t run your code, so tell us what it’s not doing that it should, or what it’s doing that it shouldn’t.
Remember, you have to do this for (0 <= x <= 4*pi) so be sure to define your ‘x’ vector, and supply the relevant elements of it to your ‘xbsin’ calculation at each step. The assignment wants at least 20 values of ‘x’ for your code as it increases the number of terms, so define your ‘x’ vector first. Iterate through that at each step as you add terms to your series. Remember, ‘epsilon’ has to take the difference of the entire series at each step as you add terms.
I would run this on paper first, calculating it with a hand calculator for a particular value of ‘x’, perhaps pi/4 and 5*pi/4. That will give you a general idea of what you’re doing.
Judging by the Mfile that you attached you already know enough MATLAB code to be able to solve this yourself. The challenge for you now is not writing the code but rather understanding how to solve the problem. Yes, there is a big difference between these! Break the problem down and do not try to write a whole page of code without actually knowing how it really works... this is doomed to be a struggle.
You could even, as Star Strider suggests, solve this first on some paper: go through some iterations, see what values you need to keep track of and when these work successfully convert them into code form. While you are working through by hand, consider which values are useful to keep, give them sensible names and write them out in a table. You can compare these with your code later.
You goal now is not code writing but to figure out an algorithm, and this is much more abstract thinking... but being systematic and using all of your available resources will get you there :)
I highly recommend reading the book "How to Solve It" by George Polya, which gives very good advice on how to approach problem-solving tasks like this one: note that the book's first principle is also "Understand the problem".
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

