How to save for loop output to column vector
조회 수: 5 (최근 30일)
이전 댓글 표시
I create a for loop and want the output to be saved in a column vector, so that each output forms a consecutive row of the vector, but I am not sure how to do this. Here is what I have so far:
% just creating the variables
fvf= 2888.7
ccm = 3*10^8*100
h = 6.63*10^-34
v1 = ccm*fvf
invAvkg = 1/(6.022*10^23)/1000
u1 = 35/36*invAvkg
k = 4 * u1 * (v1^2) * pi^2
r1 = 127.5*10^-12
I1 = u1 * r1^2
B1 = hbar^2/2/I1
for JR = [0:3]
delER = (h*v1 + 2*(JR+1)*B1)/h/ccm
end
for JP = [1:3]
delEP = (h*v1 - 2*JP*B1)/h/ccm
end
댓글 수: 0
채택된 답변
David Hill
2021년 10월 11일
No loops needed, although you never defined hbar.
fvf= 2888.7;
ccm = 3*10^8*100;
h = 6.63*10^-34;
v1 = ccm*fvf;
invAvkg = 1/(6.022*10^23)/1000;
u1 = 35/36*invAvkg;
k = 4 * u1 * (v1^2) * pi^2;
r1 = 127.5*10^-12;
I1 = u1 * r1^2;
B1 = hbar^2/2/I1;
JR = 0:3;
delER = (h*v1 + 2*(JR+1)*B1)/h/ccm;
JP = 1:3;
delEP = (h*v1 - 2*JP*B1)/h/ccm;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!