need general coding/ command to separate matrix data
显示 更早的评论
I have a for loop y= 0:2:8 and whenever the for loop value chnaged it generates two values which was stored in a matrix. Now I have a complete matrix in which column one have y=0 then several values in a rows then y changed and several vlaues in a row as shown in fig.
final matrix is:
0 5 9
0 7 3.3
0 5.5 9
1 4.0 3.5
1 2 3.3
...................... so on.
Question: I need a general coding that store number of rows in a seperate matrix/ vector when y value is fixed. I mean when y=0 then all rows with y=0 stored in a seperate vector/ matrix. Then again y changed and results in several rows. These rows stored in a seperate vector/matrix.
Your support will be highly appreciated.
Regards
4 个评论
ix=(y==0); % the logical addressing vector -- NOTA BENE: size(y,1) must equal size(M,1)
M(ix,:)=RHS; % store vector RHS at those rows -- NOTA BENE: numel(RHS) must equal size(M,2)
Muhammad Asad
2022-9-7
Stephen23
2022-9-7
Keeping data together is usually better than splitting it apart. How will you process the data?
Muhammad Asad
2022-9-7
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!