How to store the output of a loop in a matrix/vector when the loop is not indexed?
이전 댓글 표시
Hi everyone, I'm new in matlab and i need to store the output of a loop in a vector. the problem is that the loop is not indexed therefore i cannot create a vector of zeros where to store the output. My code looks as follows
a=-1;
b=-1;
p=-0.5;
a1 = a./sqrt(2*(1-p^2));
b1 = b./sqrt(2*(1-p^2));
for xj = [0.10024215,0.48281397,1.0609498,1.7797294,2.6697604];
xi = [0.10024215,0.48281397,1.0609498,1.7797294,2.6697604]';
f1 = sum(exp( a1.*(2*xi - a1) + b1.*(2*xj-b1) + 2*p.*(xi-a1).*(xj-b1)))
end
and my output looks as follows
f1 =
0.121232883313475
f1 =
0.043069611850309
f1 =
0.009189704089853
f1 =
0.001377436854364
f1 =
1.344664406705558e-
I need to store that in a vector. Could somebody please tell me what's the correct way to do it ? Thaanks :)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!