Exacting a constant range/window of values from a matrix (skipping one cell each time).
1 回表示 (過去 30 日間)
古いコメントを表示
Hi all,
I have a variable of values, X (1000 x 1) and want to create a separate variable, Y which is made up from values 1:24, skip one cell, then the next 24 values, skip one cell etc etc. until a certain value or the end of the matrix.
I feel like it should be reltively simple but just can't seem to quite get it right. Any help would be much appreciated.
Thanks in advance.
0 件のコメント
採用された回答
KALYAN ACHARJYA
2022 年 10 月 27 日
data=rand(1000,1);
data(25:25:1000)=[];
temp=length(data)/24;
cell_data=mat2cell(data,24*ones(1,temp))
1 件のコメント
KALYAN ACHARJYA
2022 年 10 月 27 日
Each cell element consist of 24x1 values, the good way to handle multiple array is using cell array, as shown in the code.
その他の回答 (1 件)
RAGHUNATHRAJU DASHARATHA
2022 年 10 月 27 日
As per my understanding you want to skip every 25th value of a matrix.
I will try to explain it using an example below .
A=1:1000;
B=A'
for i=1:38
B(i*25)=[];
end
output=B
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!