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

 채택된 답변

Star Strider
Star Strider 2022년 3월 23일
Try something like this —
plot(x,y,'DisplayName', sprintf('E = %5d',E))
Change the sprintf format string to produce the desired result.
.

댓글 수: 2

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by