||
b ={1 1 1 1 NaN; 1 1 NaN NaN NaN; NaN NaN NaN NaN NaN};
%%删除全为NaN的列
b(:,find(all(cellfun(@(x) isnan(x),b))))=[];
%%删除全为NaN的行
b(find(all(cellfun(@(x) isnan(x),b),2)),:)=[];
如果出现
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
改为:
b(:,find(all(cellfun(@(x) any(isnan(x)),b))))=[];
参考网址:
http://blog.csdn.net/lqhbupt/article/details/18265985
http://www.ilovematlab.cn/thread-24715-1-1.html
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-29 00:18
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社