Plotting spectra...(rescaling x axis)
Show older comments
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.
Answers (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 Comments
Tamas
on 2 Aug 2013
dpb
on 2 Aug 2013
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?
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!