Home > matpower7.1 > extras > syngrid > lib > nsw_get_nonzero.m

nsw_get_nonzero

PURPOSE ^

get non zero elements from matrix x,

SYNOPSIS ^

function y = nsw_get_nonzero(x)

DESCRIPTION ^

 get non zero elements from matrix x,
 put them into a col-vec - y
 by Kyli wzf, 04/07

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y = nsw_get_nonzero(x)
0002 % get non zero elements from matrix x,
0003 % put them into a col-vec - y
0004 % by Kyli wzf, 04/07
0005 
0006 %   SynGrid
0007 %   Copyright (c) 2007, 2017-2018, Electric Power and Energy Systems (EPES) Research Lab
0008 %   by Zhifang Wang, Virginia Commonwealth University
0009 %
0010 %   This file is part of SynGrid.
0011 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0012 
0013 [n,m]=size(x);
0014 x_vec = reshape(x,n*m,1);
0015 pos = find(x_vec~=0);
0016 y = x_vec(pos);
0017 % [I,J] = find(x~=0);
0018 % y = zeros(length(I),1);
0019 % for ni = 1:length(I)
0020 %     y(ni) = x(I(ni),J(ni));
0021 % end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005