How can I get a plot legend to give a different value for every input file?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
See Also
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!