[Scilab-users] Function to remove rows or colums with missing values
Samuel Enibe
samuel.enibe at unn.edu.ng
Tue Oct 2 23:25:40 CEST 2012
Thank you so much, Samuel.
Your example worked very well, and I have incorporated it in my work using
the following function:
function m = removenan(m, direction)//remove any row or column with missing
values
if (direction(1)=="r") then
m(:,or(isnan(m),'r')) = [];//delete all columns with %nan
else
m(or(isnan(m),'c'),:) = [] //delete all rows with %nan
end
endfunction
Samuel Ogbonna Enibe
University of Nigeria, Nsukka, Nigeria
On Tue, Oct 2, 2012 at 7:44 PM, Samuel Gougeon <sgougeon at free.fr> wrote:
> **
> Hello,
>
> Le 02/10/2012 19:33, samuel.enibe at unn.edu.ng a écrit :
>
> Dear sir,
>
> Is there an existing function in SCILAB to remove all rows or columns with with one or more missing values from a matrix such as X.
>
> I want to avoid the alternative of using the scipts such as
> K = find(isnan(X))
> And then converting the K to row,column format before deleting the rows or columns with missing values.
>
>
> I am afraid that a set of instructions is required. One possibility is
> the following
> (to delete *columns* with one or more %nan) :
>
> m = rand(5,5);
> m(3,2) = %nan;
> m(2,4) = %nan
>
> m(:,or(isnan(m),*'r'*)) = []
> // m(or(isnan(m),*'c'*),:) = [] // for rows
>
>
> Regards
> Samuel
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121002/07693dd0/attachment.htm>
More information about the users
mailing list