フィルターのクリア

Splitting of a column to multiple columns

32 ビュー (過去 30 日間)
Olu B
Olu B 2019 年 7 月 9 日
編集済み: Stephen23 2019 年 7 月 12 日
Hi,
If I have a 100 x 1 column of numbers between -1 to 100 and i want to eliminate the 0's and negative numbers, then split the column into 10 rows each and call each row a given name so as to plot them against each other.
Could you advise how to do this, thanks
  6 件のコメント
jahanzaib ahmad
jahanzaib ahmad 2019 年 7 月 9 日
sir @Stephen Cobeldick whats the easy way to split 100x1 into 10 columns of 10x1
a=n(1:10,:);b=n(11:20,:);c=n(21:30,:);d=n(31:40,:);e=n(41:50,:);f=n(51:60,:);g=n(61:70,:);h=n(71:80,:);i=n(81:90,:);
j=n(91:100,:);
Stephen23
Stephen23 2019 年 7 月 10 日
編集済み: Stephen23 2019 年 7 月 10 日
" whats the easy way to split 100x1 into 10 columns of 10x1 "
There is no easy way to do that "automatically". In fact, you should avoid doing that (unless you want to force yourself into writing slow, complex, buggy code which is hard to debug).
The best solutions would be to either reshape the array (e.g. as Renato shows), or split the data into a cell array (e.g. using num2cell or mat2cell).

サインインしてコメントする。

回答 (1 件)

Renato SL
Renato SL 2019 年 7 月 9 日
After doing what Stephen Cobeldick suggested in the comments, I believe this would do it.
n2 = reshape(n,[],10);
  6 件のコメント
Olu B
Olu B 2019 年 7 月 11 日
Thanks for your help. This works
Stephen23
Stephen23 2019 年 7 月 12 日
編集済み: Stephen23 2019 年 7 月 12 日
@Olu B: note that splitting up your data makes it harder to work with.
Using indexing is much simpler.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by