Adding Legend to a multiple graph within a loop
Show older comments
Hello there!
I am writing a short code for plotting data from COMSOL.
These data concern the attenuation loss of a bent loss for fifteen curvature radii against twenty-seven wavelength forming a 405 X 3 matrix. I need to overlay each plot within the same image and to label each one by the relative curvature radius. I succeeded to complete the first part of the task but I really cannot add the legends. Could anyone please help me?
clear all
close all
clc
hold on
data=dlmread('data.txt')
for i= 1:27:378
for j = 28:27:405
for k=1:15
txt = ['X = ',num2str(k)];
plot(data(i:j,2),data(i:j,3), 'DisplayName' ,txt)
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!