How to Plot a Date on the X Axis using xlsread?
Show older comments
I've read in an excel file using:
>>[num,txt,raw] = xlsread(FilePath, sheet, range);
having my code in previous steps specify the FilePath, sheet, and range; they read in to the "raw" array exactly as I want them to.
What I want to do is plot a few of the "columns" from the raw array. Specifically, I want the first column to be the x-axis, with 3 other columns as lines in the y-axis. But I want the x-axis to be in some sort or date format- preferably MM-YYYY. When I plot it by using the plot toolbar on the top of the Matlab program, it gives me this code:
>> plot(cell2mat(raw(:,[17,19,end])),'DisplayName','cell2mat(raw(:,[17,19,end]))')
which plots the data exactly as I want it to, but the x-axis is not the date- it's just a number from 1-365 (I guess just the row number).
Any help or advice with this?
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets 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!