How to save output in different column for each loop
4 次查看(过去 30 天)
显示 更早的评论
Good day everyone, I have wrote a for loop, and code as following:
Vg=[]
for i=0:2:10
y=Rawdata(:,2+i);
y_data=find(y>0.9e-9 & y<1.8e-9)
Vg=[Vg; x(y_data)]
end
I want to save the result in different column instead of single column. How to achieve it? Because it's single column now.....
Thank you.
0 个评论
回答(1 个)
Harish Ramachandran
2018-2-1
I am not sure what x(y_data) is.
However, I will try to give you a trivial example which you can probably use to scale for your problem. Below is a piece of code to append 5*i based on each iteration i of the for loop.
V = [];
for i=1:10
x = 1:5
V = [V ; i.*x'];
end
This results in the resultant V being a vector of 50x1 which I believe is similar to your case. On making the required change (as in the code below) you will be able to save the result to a different column.
V = [];
for i=1:10
x = 1:5
V = [V i.*x'];
end
Now V is a 5x10 double vector.
V =
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
Hope this helps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!