How to save Data Individually
1 次查看(过去 30 天)
显示 更早的评论
I Have a Data
like 2000*5 i.e 2000 rows with 5 colomns.
I would like to save this the data in to five varaible like x1,x2,x3,x4 and x5 where x1 consisting of 1st coloms of x.
The MATLAB code must be any loop function.How to Write and save 2000*1 data of 5 different variables using a loop statement with MATLAB
2 个评论
回答(1 个)
Addy
2022-2-9
It is bad to use eval to create variables in loop.
So, you can do it manually like
x1 = x(:,1);
x2 = x(:,2);
....
Or in a loop to store in a cell
for i=1:size(x,2)
x_cell{:,i} = x(:,i);
end
Or just use num2cell
x_cell = num2cell(x,1);
另请参阅
类别
在 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!