Error message says not enough input arguments

1 view (last 30 days)
Abigail
Abigail on 27 Sep 2013
Answered: Wayne King on 27 Sep 2013
clear; clc; close all
W=input('Enter your wavelength in nanometers from 400nm to 700nm:\n');
if W>700 || W<400
fprintf(2,'Warning: Your input wavelength is not within the spectrum of visible light (400nm to 700nm).\n')
end
if W>400 && W<=450
color=='violet';
elseif W>450 && W<=490
color=='blue';
elseif W>490 && W<=560
color=='green';
elseif W>560 && W<=590
color=='yellow';
elseif W>590 && W<=635
color=='orange';
elseif W>635 && W<700
color=='red';
else
color=='not in the spectrum of visible light.'
end
fprintf('Your wavelength''s color is %s.\n',color)
so when input W=500, this is what comes out:
Error using color (line 19)
Not enough input arguments.
Help please!

Answers (1)

Wayne King
Wayne King on 27 Sep 2013
You don't want color == , you want color =
W=input('Enter your wavelength in nanometers from 400nm to 700nm:\n');
if W>700 || W<400
fprintf(2,'Warning: Your input wavelength is not within the spectrum of visible light (400nm to 700nm).\n')
end
if W>400 && W<=450
color='violet';
elseif W>450 && W<=490
color='blue';
elseif W>490 && W<=560
color='green';
elseif W>560 && W<=590
color='yellow';
elseif W>590 && W<=635
color='orange';
elseif W>635 && W<700
color='red';
else
color='not in the spectrum of visible light.'
end
fprintf('Your wavelength''s color is %s.\n',color)

Tags

Community Treasure Hunt

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

Start Hunting!