How to plot a graph in nm

조회 수: 21 (최근 30일)
laura byrne
laura byrne 2021년 2월 4일
답변: Daniel Pollard 2021년 2월 4일
I want to plot a graph with wavelength on the x axis but when i input the wavelength values I convert them to meters for the calculation of y axis values. Is there a way to have the wavelength values in nm without adding a second matrix? This is what I have
theta = 10
wavelength_m = [500e-09:10e-09:700e-09]
wavelength_nm = [500:10:700]
m = 1
d = (m.*wavelength_m)/sin(theta)
spatial_frequency = 1./d
plot(wavelength_nm,spatial_frequency,"r--")
xlabel("Wavelength (nm)")
ylabel("Spatial Frequency (/m)")

채택된 답변

Daniel Pollard
Daniel Pollard 2021년 2월 4일
Your method works perfectly well. An alternative option would be
theta = 10
wavelength = [500:10:700]
m = 1
d = (m.*wavelength)/sin(theta)
spatial_frequency = 1./d
plot(wavelength*1e-9, spatial_frequency,"r--")
xlabel("Wavelength (nm)")
ylabel("Spatial Frequency (/m)")
where I've used one vector of wavelengths (in meters) and then multiplied it by 1e-9 for the plot.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by