필터 지우기
필터 지우기

Error: Why does Matlab keep on saying this?

조회 수: 2 (최근 30일)
Mahmud Khan
Mahmud Khan 2018년 9월 6일
댓글: Mahmud Khan 2018년 9월 6일
As part of an exercise, I wrote the following code:
%define colors for each face
myred = [1, 0, 0];
mygreen = [0, 1, 0];
myblue = [0, 0, 1];
myyellow = [1, 1, 0];
mycyan = [0, 1, 1];
patchcolors = [...
myred;... %front
mygreen;... %back
myblue;... %right
myyellow;... %left
mycyan;... %top
mycyan;... %bottom
];
For the line starting with myred =...., the command window says:
" The expression to the left of the equals sign is not a valid target for an assignment."
The editor shows this:
If I hover my cursor over the highlighted errors, this is what I get:
I don't see what is obviously wrong with the code. In fact, if I write the exact same line under that first line (myred=....), Matlab seems to find no error in it.
Advice? Suggestions?
  댓글 수: 3
Guillaume
Guillaume 2018년 9월 6일
Most likely you're missing a closing ), } or ] on a line before the error. Post (or attach) your whole code.
Mahmud Khan
Mahmud Khan 2018년 9월 6일
편집: Mahmud Khan 2018년 9월 6일
No need to bother with this. I solved what the problem was.
What happened is that I didn't terminate the piece of code that went BEFORE this piece. As a result, Matlab was trying to interpret this code as part of the one that went before it.
Both Dennis and Guillaume were right about their suspicions. Thanks for trying to help :)

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

채택된 답변

YT
YT 2018년 9월 6일
The problem lies not with the code you provided, but with the code before that. I see that in your second screenshot, you ended your previous array with:
9,10,11,12,... %bottom
You just forget to add the bracket there
9,10,11,12,... %bottom
];
  댓글 수: 2
Dennis
Dennis 2018년 9월 6일
patchcolors = [...
%code
];
Mahmud Khan
Mahmud Khan 2018년 9월 6일
Thanks.
That is exactly what happened. :P My bad.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by