Heya,
For my class i have to Create a Algorithm to Approximate something and calculate the relative error but i can't seem to find the right way to Output it.
so we're given something like this (Wich we have to use exactly like this) "[Approximation,RelativeError] = Algorithm(x,n)". we must output it in a 1x2 vector, but everytime i call the function, only the Approximation is in the "ans". i know, that i can force it to give me both outputs, by inputting "[Approximation,RelativeError] = Algorithm(x,n)" (Wich i don't think the MatLab Grader we're using is doing) or just creating a Vector like A = [approximation,RelativeError] but the Grader won't check in the Vector A.
is there a way to Output that Function in a Vector by just Inputting "Algorithm(x,n) ?

 Accepted Answer

Guillaume
Guillaume on 1 Nov 2018

0 votes

If the signature of the function you've asked to implement is [Approximation,RelativeError] = Algorithm(x,n) then grader will call that function with something like [a, b] = Algorithm(testx, testn), unless the person designed the test made a serious mistake of course.
If you must return a 1x2 vector consisting of approximation and error, then the function cannot have the above signature. It would have to be ApproxRelerror = Algorithm(x, n).
The two syntaxes are completely different and there's nothing you can do on your side to make grader work with one signature if it expects the other.
Does grader show the code it uses to test your solution?

More Answers (0)

Categories

Asked:

on 1 Nov 2018

Answered:

on 1 Nov 2018

Community Treasure Hunt

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

Start Hunting!