Plotting spectra...(rescaling x axis)

Hi there,
I would greatly appreciate any help for this simple enough issue:
I have a spectra to plot (2D), with 1201 rows (x), and 74 columns (y). My x is a range of 200nm- 800nm. This is what I would like to display on the x axis proportionally. Although Matlab plot function automatically display my sample number which is 1201 (0- 1201 etc). How could I re-scale my x axis without losing any information and displaying my x from 200nm to 800nm.
Hope this is clear enough explanation...
Again, greatly appreciate any help...
Thank you in advance.

回答(1 个)

dpb
dpb 2013-8-1
编辑:dpb 2013-8-1
Simplest is to simply build the x vector and use it to plot() against instead of the default index vector.
If it is indeed linear from 200:800 for 1201 points, then linspace is your friend...
x=linspace(200,800,length(y))'; % Use length(y) for dynamic matching...
plot(x,y)
NB the "'" transpose on x to create a column vector to make the shape commensurate w/ the y array since linspace returns a row vector.

2 个评论

So great help...it works fantastic...Thank you...
(In addition to this, I am using Matlab 2011, is it a common issue that I cannot read a full content of a 1201 (rows)X 740 (coloumns) by xlsread? It only reads 22 cols?)
Very much appreciate it all,
Thank you...
Don't know; whatever happens w/ Excel isn't Matlab... :)
But surely it can read well over 22 columns so I'd guess there's something in col 23 (like text, maybe?) or perhaps it's empty or somesuch that causes the read to be truncated.
Use the optional additional outputs to xlsread to see what is in the TEXT and RAW cells to find out more about what's going on. Also you can try the RANGE input argument but I suspect whatever caused the automagic results will override it and leave w/ same thing but who knows???
Provide a sample of a line if above doesn't bring joy...meanwhile how about "Accepting" the previous answer to that question as this appears to be a different one?

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息

标签

提问:

2013-8-1

Community Treasure Hunt

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

Start Hunting!

Translated by