How to generate a legend with different values inside a loop
Show older comments
I am trying to put in the legend the values of E for each graph. So for i=0 I would like to have in the legend the value of E=50000. This is the code I have so far:
for i=0:25000:150000
x = 0 : 0.25 : 5
E = 50000 + i
y = (4*E.*x)/((1-nu^2)*D_e^2*N).*((h-x).*(h-x/2)*t+t^3)
plot(x,y,'DisplayName','E')
xlabel('Displacement(mm)')
ylabel('Force(N)')
hold on
lgd = legend;
lgd.NumColumns = 2;
end
Accepted Answer
More Answers (0)
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!