How to save Data Individually
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 9 Feb. 2022
Bearbeitet: Stephen23
am 9 Feb. 2022
"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)
Antworten (1)
Addy
am 9 Feb. 2022
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);
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!