I want to create two different matrices from a single matrix.

1 回表示 (過去 30 日間)
Maruti Patil
Maruti Patil 2015 年 4 月 15 日
コメント済み: Maruti Patil 2015 年 4 月 15 日
suppose I have a column matrix
u = [2.2717e-33; -5.4589e-33; 5.2283e-33; -2.4541e-32; 4.7101e-12; -8.2867e-12; 1.2316e-12; -2.42e-11; 5.4588e-33; -6.9569e-11; -1.7921e-11; -7.563e-12; -1.8645e-11; -2.7506e-11; -1.2959e-32; -5.452e-11]; I want to create two matrices one for even numbers of rows and other for odd numbers of rows. How to do it?? Please help thanks.

採用された回答

Guillaume
Guillaume 2015 年 4 月 15 日
編集済み: Guillaume 2015 年 4 月 15 日
It's simple indexing:
oddu = u(1:2:end)
evenu = u(2:2:end)
A more generic solution that gives you odd and even rows for matrices as well as vectors:
oddrows = m(1:2:end, :);
evenrows = m(2:2:end, :);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by