i used a function that would delete columns with any negative elements in them
i had 9 columns now i'm left with 6 columns
problem is that the 3 i purposly rejected come out as a Empty matrix: 321-by-0
how can i tell matlab to ignore this completly so i can work with the correct 6 columns ?

4 commentaires

KSSV
KSSV le 15 Mar 2019
Not sure how your code is..but I guess isempty might help you to know ehter the arrray is empty or not.
omar mahallawy
omar mahallawy le 15 Mar 2019
i know that there are empty arrays, i used this to reject the unwanted arrays
idx = any(A<0);
A = A(:,~idx)
problem is that when i want to multiply the un-rejected arrays an error comes up saying that Matrix dimmensions disaagree
so all i wanted is to delete the empty matrix to continue with my code peacefully
madhan ravi
madhan ravi le 15 Mar 2019
illustrate with a short example
We need a lot more details to understand what you're doing. Most likely, you're doing very something wrong. There's already a problem with the 2 lines you've shown, which should be:
idx = any(A < 0, 1); %use ,1 to make sure you operate along the rows
A = A(:, ~idx);
"so all i wanted is to delete the empty matrix to continue with my code peacefully"
delete from what? From memory? If your code was expecting a variable and you've deleted from memory, it certainly won't continue peacefully. To me, this sounds like an XY problem where you've got a problem and ask us to fix it using a solution that is completely inappropriate (delete a matrix) instead of describing the real problem.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Manage Products dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by