How do I plot this to display a spectrum?

I want to plot the intensity against wavenumber.
This is the intensity i believe:
But i dont understand what's val(:,:,1) this runs till val(:,:,729)
and this is the wavenumber:
and it runs from 1 to 729
i tried to plot x = wavenumber and y = ref_Raw and plot (x,y)
however it was reflected
??? Error using ==> plot Data may not have more than 2 dimensions
do need help with this!
thanks

 채택된 답변

Rick Rosson
Rick Rosson 2014년 10월 11일

0 개 추천

x = wavenumber;
y = transpose(squeeze(ref_raw));
plot(x,y);

추가 답변 (1개)

hithere
hithere 2014년 10월 11일

0 개 추천

Thanks alot!
But may I roughly know i would need to transpose. and whats the purpose of squeeze command?
thanks!

댓글 수: 3

Rick Rosson
Rick Rosson 2014년 10월 11일
편집: Rick Rosson 2014년 10월 11일
The variable ref_raw is a 25 x 1 x 729 array. To verify, please type
size(ref_raw)
at the command prompt. In MATLAB, this array has 3 dimensions:
ndims(ref_raw)
The plot function does not allow arguments that have more than 2 dimensions. But notice that the size of the middle dimension is exactly 1. As a result, it is unnecessary. In MATLAB, this dimension is called a singleton dimension. The squeeze function eliminates singleton dimensions.
In this case, the result of calling squeeze is to convert raw_ref to a 25 x 729 array, which is 2D and contains all of the same numeric values.
Finally, the transpose simply converts the array to 729 x 25. The reason the transpose is necessary is because the plot function treats each column as an independent data series. Because the wavenumber variable contains 729 values, I inferred that you wanted to plot 25 different spectra, each consisting of 729 values.
hithere
hithere 2014년 10월 11일
Thanks mate! Sorry for the trouble, im still learning.
Thanks alot!
Rick Rosson
Rick Rosson 2014년 10월 11일
No need to apologize. We are all still learning. When we stop learning, then it's time to throw in the towel!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 10월 11일

댓글:

2014년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by