Given 2 red beads, 2 blue beads, 1 yellow bead, and 1 green bead, how many different necklaces can be made?

조회 수: 2 (최근 30일)
I need a matlab code that will determine the answer (the answer is given as 16 and I keep getting 30). Flips and circular shifts need to be taken out as well using loops

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2019년 10월 18일
Why not just remove the non-unique necklaces? See the help and documentation for unique for how to do this.
HTH
  댓글 수: 4
SammyJoe
SammyJoe 2019년 10월 18일
I tried this, seems to be an error in the second line; is there a way to make a matrix with this loop?
Bjorn Gustavsson
Bjorn Gustavsson 2019년 10월 18일
Change p2(km :); to: p2(k,:); That should fix that problem.
For future work, read the error message look at what it says, look at the code snippet and try to see if you can spot the error. You most likely got an error-message along the lines of "Undefined function or variable 'km'." You will have to learn to spot that kind of error sooner or later, the sooner you do the better for you.
HTH

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by