How do you I get my program to label the axes using the column headings in my excel file?

5 views (last 30 days)
I have three column headers in an excel file: A1:A1 is time, B1:B1 is velocity. This is what I have so far but I cant get my plot to label the axes. Please help me out .
clear;
clc;
data = xlsread('veldata.xlsx');
t = data(:,1);
v1 = data(:,2);
v2 = data(:,3);
avg_v1v2 = ((v1 + v2)/2);
plot(t,v1,'b',t,v2,'g',t,avg_v1v2,'r:')
xlabel(xlsread('veldata.xlsx','Sheet1','A1:A1'))

Accepted Answer

Image Analyst
Image Analyst on 2 Nov 2014
[data, txt, raw] = xlsread('veldata.xlsx');
% other code...
col1Header = txt{1, 1};
col2Header = txt{1, 2};
xlabel(col1Header, 'FontSize', 25);
ylabel(col2Header, 'FontSize', 25);
Adapt as needed.

More Answers (0)

Categories

Find more on Data Import from MATLAB 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!