Hello all, I have a function that takes an Excel file as an input, and outputs a graph using the 2nd column of numbers as the x values and the 3rd column of numbers as the y values. This is my script:
function plotData(filename, markers) a=xlsread(filename); hold on; title(filename); x=a(:,1); y=a(:,2); if markers==true plot(x,y,'-o') elseif markers==false plot(x,y) end
The problem I am having is naming the x axis and y axis. I need help fixing the script so that it takes the first entry from each column as a string, and names the x and y axis with this. Here is what the Excel file looks like:
A B1 2 time (sec)height (meters) 3 0 2004 1 1955 2 1806 3 1557 4 1208 5 759 6 20
The output should be a plot of the data (which works fine) with the x axis labeled 'time(sec)' and the y axis labeled 'height (meters)'. I know how to label them by 'xlabel' and 'ylabel' but I need the script to take the names from the Excel file as a string and label them instead of me manually entering the names into my MATLAB script.
Best Answer