How to concatenate value calculated in a for loop?
1 次查看(过去 30 天)
显示 更早的评论
In matlab, if I have a code that calculates the rate of something in a for loop like this
for t=1:10
Ratek=(1/2)*(log2(1+SINR1k)+log2(1+SINR2k));
end
and each time the value of the rate differs, I want in to concatenate all the values of this rate in each loop so that after the 10th loop I have the 10 rates calculated to use them. How can I do this ?
0 个评论
回答(1 个)
Matz Johansson Bergström
2014-7-19
I guess you want to place the values in a vector?
Ratek = zeros(10,1); %preallocate vector
for t=1:10
Ratek(t) = (1/2)*(log2(1+SINR1k)+log2(1+SINR2k));
end
Is this what you need?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!