Problem with using reshape
4 ビュー (過去 30 日間)
古いコメントを表示
I have a problem using reshape function. I want to extract my angles from data matrix into new matrix, dividing them into 2 colums (new column for each angle).
This is my data matrix:
data =
-13 -1515,21041600000
-13 -1472,44425940753
-13 -1073,29699036918
-13 -1038,18702400000
-13 -1037,46604000000
-13 -726,128784972022
-13 -593,565533279872
-13 -487,207584000000
-13 -472,548334667734
-13 -407,240495207668
-13 -405,700448000000
-12 -1515,21041600000
-12 -1472,44425940753
-12 -1073,29699036918
-12 -1038,18702400000
-12 -1037,46604000000
-12 -726,128784972022
-12 -724,533918269230
-12 -593,565533279872
-12 -487,207584000000
-12 -472,548334667734
-12 -407,240495207668
-12 -405,700448000000
This is what I want to get:
angles =
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
-13 -12
I tried using reshape function for it, something like this:
angles=reshape(data(:,1),[],2)';
But since each of my angles repeat 11 times, I have 23 rows in my data matrix so I get error like this:
Error using reshape
Product of known dimensions, 2, not divisible into total number of elements, 23.
EDIT: I found the problem in the rest of my code which caused my first angle to have 1 less entry. Sorry for wasting your time.
0 件のコメント
採用された回答
Walter Roberson
2019 年 6 月 1 日
No that cannot be done by reshape alone. You have 11 entries with 13 but you have 12 entries with 12. Are you willing to discard the last entry to make the same number of each?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!