Error Variable Spectrum has an incorrect value.
16 views (last 30 days)
Show older comments
Sean St Cyr on 7 Jul 2020
Answered: Walter Roberson on 10 Jul 2020
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
elseif value >=450 && value < 490
elseif value >=490 && value <560
elseif value >=560 && value <590
elseif value >=590 && value < 635
elseif value >=635 && value <=700
fprintf ('Not Visible');
Sai Sri Pathuri on 10 Jul 2020
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.
Walter Roberson on 10 Jul 2020
You did not emit newlines after the color names.
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!