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 件のコメント
Stephen23
2022 年 2 月 9 日
編集済み: Stephen23
2022 年 2 月 9 日
"I would like to save this the data in to five varaible like x1,x2,x3,x4 and x5"
That is very unikely to be a good approach:
You can simply access the data directly from the matrix using basic indexing, or split the matrix into a cell array:
C = num2cell(M,1)
回答 (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!