Hi,
I am having trouble in plotting, I want to plot the graph where x-axis are names and y-axis numbers but I am getting the error below. what is solution for that.
Code:
close all; clear all; clc;
file = ["C:\Users\Alphagamma\alphagamma.xlsx];
for i = 1:numel(file)
a=readtable(file(i));
names = a{:,3}
values = a{:,5}
end
figure()
plot (names,values)
Error:
>> figure()
plot (names,values)
Error using plot
Invalid data argument.

2 commentaires

You can only plot numeric data. But x label you can change with the help of xTickLabels
set(gca, 'xTickLabels', XlabelStr);
muhammad choudhry
muhammad choudhry le 13 Sep 2022
Modifié(e) : muhammad choudhry le 13 Sep 2022
Hi,
what am I doing wrong here I added the piece of code you mentioned!
is there no way it will read the names from the excel ?
Code:
set(gca, 'xTickLabels', names);
figure()
plot (names,values)
Error:
plot (names,values)
Error using plot
Invalid data argument.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 13 Sep 2022
plot( categorical(names), values)

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by