How to delete rows/columns of a matrix in Embedded Matlab Fcn?
4 vues (au cours des 30 derniers jours)
Mike Hosea le 9 Juil 2013
I don't know what version you have. MATLAB Coder does currently support deleting rows and columns from a matrix. You will need to start with a variable-size matrix, of course. Use coder.varsize to make any matrix that looks like a fixed-size matrix into a variable-sized one.
You can write something like:
z(rowstodelete,:) = ;
z(:,colstodelete) = ;
where rowstodelete and colstodelete are vectors of row and column indices, respectively. To do both rows and columns at once, I might rather write code like this
ONE = int32(1);
rowsleft = setdiff(ONE:size(z,1),rowstodelete);
colsleft = setdiff(ONE:size(z,2),colstodelete);
z = z(rowsleft,colsleft);
I have to warn you of one thing, however. You will not be able to coax it into making that last assignment an in-place operation. We're working on it. :) -- Mike
Plus de réponses (2)
Guru le 7 Juil 2013
The Embedded MATLAB Fcn is intended for MATLAB that would resemble C code. How do you suppose you can delete rows/columns from a matrix in C?
That is a rhetorical question, but the answer is quite simply you cannot, nor should you be trying to do so. I have never wrote C for Embedded Systems where I had to delete a row/column from a matrix type of functionality. That is only the case where I didn't know enough about my system to not know how much to allocate for every data that I had.
Short answer: You cannot do so, nor should you be able to as it is not what Embedded MATLAB Fcn is intended for.