Is the closing end necessary in functions in CodeRunner?

Is the closing end necessary in functions in CodeRunner?

de către Juha-Matti Huusko-
Număr de răspunsuri: 2
Student answer is
function result = operation(a,b)
result=a*b+max(a,b);
end

Is the closing end necessary? Can the student answer be just
function result = operation(a,b)
result=a*b+max(a,b);

Besides CodeRunner, I know both kinds of examples, such as
  • The closing end is not necessary in Matlab.
  • Closing end is necessary when defining functions in Octave command line.
Ca răspuns la Juha-Matti Huusko

Re: Is the closing end necessary in functions in CodeRunner?

de către Richard Lobb-
CodeRunner generates a .m file from the answer (or, strictly, the template code, incorporating the student answer) and runs it with either Octave or Matlab depending on the question type. So the rules on use of end are exactly those of Octave or Matlab respectively. If you have multiple functions in the file, you will need to terminate each one with 'end' regardless (or optionally 'endfunction' for octave).

Due to threatening noises from Mathworks regarding the interpretation of our institution's student Matlab licence, CodeRunner no longer supports Matlab out of the box. As explained in the "Question type details" section of the authoring form, even the so called "Matlab function" question type uses Octave. So unless your institution has re-activated the Matlab functionality on your Jobe server and adjusted the question types accordingly, you're probably running Octave, anyway.

I recommend switching to Python, myself ;-)
Ca răspuns la Richard Lobb

Re: Is the closing end necessary in functions in CodeRunner?

de către Juha-Matti Huusko-
Dear Richard. Thank you for a very detailed answer. :)