フィルターのクリア

how to insert a calculated index to trim a data set?

2 ビュー (過去 30 日間)
flemingtb
flemingtb 2018 年 11 月 30 日
回答済み: Mark Sherstan 2018 年 11 月 30 日
I have a matrix KeyZ that needs to be custom trimmed based on user defined dimensions. The user inputs a 'width' value in mm and i'd like to use that to set the boundary of the data. For example.
KeyZ(:,[1:110,width:end])=[];
I'm getting the following error, which makes sense i just don't know how to do it correctly.
Index in position 2 is invalid. Array indices must be positive integers or logical values.
  2 件のコメント
Georgios Pyrgiotakis
Georgios Pyrgiotakis 2018 年 11 月 30 日
What's the format of the KeyZ matrix?
flemingtb
flemingtb 2018 年 11 月 30 日
1800x800 double
I tried this, it still hung up.
Trim = KeyZ(:,[1:110,width:end]) %=[]; %Trim columns 1 - 255 and 652-end with []
Trim = KeyZ(1:100,:) %= []; %Trim rows 1-17 to []
[m,n] = size(Trim ); %Matrix Dim
[xg,yg]= meshgrid((0:n-1),(0:m-1));

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

回答 (2 件)

Georgios Pyrgiotakis
Georgios Pyrgiotakis 2018 年 11 月 30 日
I am assuming that you have a 1800 x 800 and what you are trying to do is to trim it to keep the rows
Trim = KeyZ(1:110,width:end)
Also the
Trim = KeyZ(1:100,:) %= []; %Trim rows 1-17 to []
will trim rows 101 to 1800 and keep all the columns

Mark Sherstan
Mark Sherstan 2018 年 11 月 30 日
Use a diffferent variable name then width, it is a function used for tables and is used by MATLAB. You also need to ensure that your width (or now idx variable) is greater than 110 and less than 800. The following code should work for you:
idx = 500; % index location or width
KeyZ = rand(1800,800); % Some random 1800 x 800 matrix
KeyZ(:,[1:110,idx:end]) = [];

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by