zqq0ew0的个人博客分享 http://blog.sciencenet.cn/u/zqq0ew0

博文

Matlab中cell中替换NAN值为空

已有 8952 次阅读 2018-3-15 16:48 |个人分类:Matlab|系统分类:科研笔记

  1. b ={1 1 1 1 NaN; 1 1 NaN NaN NaN; NaN NaN NaN NaN NaN};  

  2. %%删除全为NaN的列  

  3. b(:,find(all(cellfun(@(x) isnan(x),b))))=[];  

  4. %%删除全为NaN的行  

  5. 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




https://blog.sciencenet.cn/blog-628499-1104077.html

上一篇:东北地区气候变化综述 不足之处 敬请指正
下一篇:Matlab2015b下解决mex的问题
收藏 IP: 114.242.25.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-21 00:23

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部