How can I get a plot legend to give a different value for every input file?
2 次查看(过去 30 天)
显示 更早的评论
I have a code that plots some data:
D = 'My Directory';
S = dir(fullfile(D,'LIV Data T= *.mat')); % Makes a structure with all files
N = numel(S); % Counts number of files
for ii = 1:N
T = load(fullfile(D,S(ii).name)); % Load each file as a structure
I = T.num(3:end,1); % Extract each parameter from full file and ignore first two data points
V = T.num(3:end,2);
P = T.num(3:end,3);
figure(1);
plot(I,P,'-o','markers',3)
xlabel('Current (mA)')
ylabel('Power (mW)')
hold on
figure(2);
plot(I,V,'-o','markers',3)
xlabel('Current (mA)')
ylabel('Voltage (V)')
hold on
end
I am trying to create a plot legend for each data file saying T=10 for the first, T=15 for the second, etc. such that the plot has a full legend shown for each line. How do I go about this?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!