My script is not giving me the title, xlabel, and ylabel that I am asking so how can I fix it?

3 views (last 30 days)
function [xy]= plotData(filename,markers)
%data=xlsread('data.xlsx');
[num,txt]=xlsread(filename);
x=num(:,1);
y=num(:,2);
title(filename)
xlabel(txt{1})
ylabel(txt{2})
if markers==true
plot(x,y,'k-o');
else
plot(x,y,'k-');
end

Accepted Answer

Steven Lord
Steven Lord on 28 Nov 2018
Call title, xlabel, and ylabel after calling plot. By default calling plot is going to clear graphics objects from the axes, reset most axes properties to their default values, and calculate new axes limits as stated on this documentation page.

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!