Error Variable Spectrum has an incorrect value.

조회 수: 2 (최근 30일)
Sean St Cyr
Sean St Cyr 2020년 7월 7일
답변: Walter Roberson 2020년 7월 10일
I am trying to create a character array for it to print a certain color out if a random wavelength is input, and it is giving me an error saying "Variable Spectrum has an incorrect value: You have not, or incorrectly, accounted for one of the colors. Incorrect spelling or capitalization could be a problem"
value = wavelength;
Spectrum = 'violet , blue , green , yellow , orange , red , Not Visible';
if value >= 400 && value <450
fprintf ('violet');
elseif value >=450 && value < 490
fprintf ('blue');
elseif value >=490 && value <560
fprintf ('green');
elseif value >=560 && value <590
fprintf ('yellow');
elseif value >=590 && value < 635
fprintf ('orange');
elseif value >=635 && value <=700
fprintf ('red');
else
fprintf ('Not Visible');
end
  댓글 수: 1
Sai Sri Pathuri
Sai Sri Pathuri 2020년 7월 10일
Is this your entire code? I am unable to reproduce the error at my end. This code worked perfectly.
Provide the entire code and steps you followed to reproduce the error.

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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 7월 10일
You did not emit newlines after the color names.

카테고리

Help CenterFile Exchange에서 Discontinuities에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by