How do I put all values from for loop into one vector

Greetings,
As writen above i would like to be able to plot values of 'u'that comes out from for loop so i need somehow to put them in a form of a vector or whatever form suits the best.but cant figure out the code for that. my code:
umax=0.54; M=-4.2703; D=1.8;
for y=0:.1:1.8;
u=umax/M*log(1+(exp(M)-1)*(y/D)*exp(1-y/D))
end
disp(u)
tyvm in advance.

 채택된 답변

John Petersen
John Petersen 2012년 8월 2일
Y = 0:.1:1.8;
n = length(Y);
u = zeros(n,1);
for k=1:n;
u(k)=umax/M*log(1+(exp(M)-1)*(y(k)/D)*exp(1-y(k)/D))
end

추가 답변 (1개)

Imo
Imo 2012년 8월 2일

0 개 추천

that was really quick. than u very much guys.
Yours solutions worked like a charm. But on John response I can't really figure out how u=zeros(n,1) gives a values of u that are non zeroes on output, although it does.

댓글 수: 1

YES! I understand! thanks Lucas...and John ...and Azzi.

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

Imo
2012년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by