Error message says not enough input arguments
이전 댓글 표시
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!
답변 (1개)
Wayne King
2013년 9월 27일
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)
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!