how to insert a calculated index to trim a data set?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Georgios Pyrgiotakis
le 30 Nov 2018
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
0 commentaires
Mark Sherstan
le 30 Nov 2018
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]) = [];
0 commentaires
Voir également
Catégories
En savoir plus sur Numeric Types dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!