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

 Akzeptierte Antwort

Try something like this —
plot(x,y,'DisplayName', sprintf('E = %5d',E))
Change the sprintf format string to produce the desired result.
.

2 Kommentare

Thank you very much
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by