checking for colon operator in MATLAB grader

In the very first part of a course, I want to check that students are using the colon operator to create a simple vector. I've tried the following:
assessFunctionPresence(:)
assessFunctionPresence(':')
but neither seem to work.
Does anyone know if this can be done, and if so, how?

3 Kommentare

Voss
Voss am 21 Sep. 2023
Bearbeitet: Voss am 21 Sep. 2023
Have you tried this?
assessFunctionPresence('colon')
I'm not familiar with MATLAB grader, so I can't say for sure that will work, but colon is the colon operator:
colon(1,5)
ans = 1×5
1 2 3 4 5
James Wiles
James Wiles am 21 Sep. 2023
I hadn't, but I have now and it doesn't work. Thanks anyway though, should have tried that.
Dyuman Joshi
Dyuman Joshi am 21 Sep. 2023
You can try using assert()

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 21 Sep. 2023
Bearbeitet: Cris LaPierre am 21 Sep. 2023

0 Stimmen

MATLAB Grader does not have a built-in way to check for the use of operators (see this related question).
You might try combining the assessment of their variable values with banning the use of other matrix creation functions (e.g. linspace).
Consider looking at the Vector Creation (creating equally spaced vectors) sample problem in Sample Problems From MathWorks > Introduction to Programming > Matrices & Operators. It's the 2nd problem.

2 Kommentare

James Wiles
James Wiles am 21 Sep. 2023
OK Great, thanks for your help :)
If you don't yet have access to the full catalog of sample problems, please reach out to your Mathworks representative. Access is limited to verified instructors.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 21 Sep. 2023

Kommentiert:

am 21 Sep. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by