Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

op plots. 3. (20 points) The table below shows the different forms of light ener

ID: 3930697 • Letter: O

Question



op plots. 3. (20 points) The table below shows the different forms of light energy at given wavelengths () in the electromagnetic spectrum Light form Gamma rays X-rays Ultraviolet radiation l 4x10-7 m > > 109 m Visible light Infrared radiation | 10.3 m > 7x10-7 m Microwaves Radio waves 10-11 m or less 10-8 m > 10-11 m 7x10-7m22 4x107 m 10.1 m > 10.3 m Greater than 10-1 m Write a script, LightForm Name.m that identifies and classifies the form of light given the following wavelengths: a) 5 pm, b) 200 nm, c) 7 mm, and d) 8 km. Use the disp function to display both the wavelength and light information in the Command to display both the wavelength and light information in the Command Window. Conversion scale: 1 pm = 10-12 m 1 nm = 10-9 m 1 mm = 10.3 m 1km = 103 m

Explanation / Answer

wavelength_input = input('Please enter the wavelength: ', 's'); %taking wavelength as input
inputs = strsplit(wavelength_input, ' '); %splitting the input into units and the numerical magnitude
mag = double(inputs{1}); %first element of the cell taken as the numberical value
unit = inputs{2}; %second element of the cell taken as the unit

%if statements to check the unit of the wavelength input and multiplying by
%the appropriate magnitude and store the magnitude to a wavelength variable
if strcmp(unit, 'pm')
    wavelength = mag * 10^-12;

elseif strcmp(unit, 'nm')
    wavelength = mag * 10^-9;
  
elseif strcmp(unit,'mm')
    wavelength = mag * 10^-3;

elseif strcmp(unit,'km')
    wavelength = mag * 10^3;

end

%if loop to check the range in which the wavelength lies and outputting the
%light form correspondingly
if wavelength<=10^-11
    light_form = 'Gamma Rays';

elseif (wavelength<=10^-8 & wavelength>10^-11)
    light_form = 'X-rays';

elseif (wavelength<4*10^-7 & wavelength>10^-8)
    light_form = 'Ultraviolet Radiation';

elseif (wavelength<=7*10^-7 & wavelength>=4*10^-7)
    light_form = 'Visible Light';

elseif wavelength<=10^-3 & wavelength>7*10^-7
    light_form = 'Infrared Radiation';

elseif wavelength<=10^-1 & wavelength>10^-3
    light_form = 'Microwaves';

else
    light_form = 'Radio Waves';

end

%displaying wavelength and lightform using disp
disp(strcat('Wavelength: ', num2str(wavelength)));
disp(strcat('Light Form: ',light_form));