Stellar motion part 2, task 5

I'm doing the 5th task of Stellar motion part 2 and I keep getting it marked as wrong.
The solution to the task is
legend(starnames)
and even though I've tried a million ways of reentering it (restarting the task, writing it manually, copying and pasting the solution code), I keep getting a message telling me that "'legend' appears to be both a function and a variable". I can't keep going with the intro if this isn't accepted. Help :(

2 Kommentare

VISHWANATHAN
VISHWANATHAN am 24 Okt. 2025
Hint
Use the legend function with one input.
If you get an error from the legend function, check for a variable named legend in the workspace. If this variable exists, clear the variable with clear legend before submitting the task.
Mohammad
Mohammad am 28 Okt. 2025

Plz give correct clarification sir... How can i solve..?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Cris LaPierre
Cris LaPierre am 1 Jun. 2023
Bearbeitet: Cris LaPierre am 1 Jun. 2023

7 Stimmen

It appears at some point you created a variable named legend, which has overwritten the legend function.
Try adding clear legend before you use legend(starnames)

4 Kommentare

Roni
Roni am 12 Aug. 2023
thank you very much
Petra
Petra am 9 Apr. 2024
Same, thanks Chris
Ivan
Ivan am 21 Dez. 2024
Same here. Thanks for the clarification!
VISHWANATHAN
VISHWANATHAN am 24 Okt. 2025
can you give me ans

Melden Sie sich an, um zu kommentieren.

VISHWANATHAN
VISHWANATHAN am 24 Okt. 2025

0 Stimmen

Hint
Use the legend function with one input.
If you get an error from the legend function, check for a variable named legend in the workspace. If this variable exists, clear the variable with clear legend before submitting the task.

Gefragt:

am 1 Jun. 2023

Kommentiert:

am 28 Okt. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by