Filter löschen
Filter löschen

Anyone could help me solving this problem or could you refer me to any video or link that can help. I have been trying to solve it for couple of hours. Your help will be appreciated.

2 Ansichten (letzte 30 Tage)
  8 Kommentare
Walter Roberson
Walter Roberson am 20 Mai 2017
If your auto grader is saying that your existing version is correct, then go with your existing version. If your auto grader is saying that your existing version is incorrect, then perhaps you have more than one problem, with the reverse time being one of them.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 21 Mai 2017
You have
theta = a0;
while theta==0;
Your input, a0, is said to be a positive number less than pi. As it is a positive number, the test theta == 0 will fail, so the body of
while theta==0
is never going to execute.
I suggest you consider theta>0 instead of theta==0
  22 Kommentare
Wasi von Deutschland
Wasi von Deutschland am 26 Mai 2017
Roberson could you please tell me when autograder used arguments 0,1 it makes mistake for other arguments it's perfect.
Walter Roberson
Walter Roberson am 26 Mai 2017
Your code appears to return 4e-6 when called with argument 0, 1. That is a completely reasonable answer for the method of calculation that you are directed to use.
It is not a fair question: although the theoretic answer is that a pendulum of length 0 has infinite velocity and 0 period, it is also the case that a pendulum of length 0 is a point source and so cannot be said to move through any angle. Your given task is not to calculate the theoretical answer but rather to simulate the movement, and simulation requires a minimum of one time-step.
Their description of the calculation specifically talks about counting until the pendulum has "passed through" its lowest point, and if you can say with any assurance that the pendulum is "at" 1 radian then it takes a time-step to evolve to be "at" any other angle. If a pendulum of length 0 is "at" 1 radian at time 0, then no seconds later it cannot have changed to be "at" a different angle. If you want to talk about a 0 length pendulum then you would have to say that the angle is undefined, which would correspond to pendulum(1, nan) and your code returns 0 for that.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by