How can I automatically fill in the legend?
Show older comments
Hi all,
I was wondering how I can automatically fill in my legend of a plot with the names of the files I load regarding excel-files (those contain numerical matrices). The code I'm using is:
material = {xlsread('dp600_2_layers_L50.xlsx',4),xlsread('dp600_3_layers_L50.xlsx',4),xlsread('dp800_3_layers_L50.xlsx',4)};
legend(material);
Clearly, I want to name the first line "dp600_2_layers_L50", the second line "dp600_3_layers_L50", etc. The error which Matlab returns is "Cell array argument must be a cell array of strings.", which seems logical. Is there any way to work around this, or do I have to fill in the legend manually each time I change the input files?
Thank you all in advance!
Thomas
Accepted Answer
More Answers (1)
Thomas Schot
on 4 May 2016
0 votes
Categories
Find more on Legend 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!