How can I use NaN padding instead of zero padding in a MATLAB array?
51 次查看(过去 30 天)
显示 更早的评论
When I run the following example, zero padding is applied to the nonspecified indices of the array. I would like to have NaNs instead of zeros for the nonspecified indices.
X(1,1) = 7;
X(2,2) = 3;
X
This returns the following:
X =
7 0
0 3
The desired result is:
X =
7 NaN
Nan 3
采纳的回答
MathWorks Support Team
2009-12-4
The ability to use NaN padding with a single command is not available in MATLAB.
To work around this issue, you can replace all zeros with NaNs in your array using the following example:
X(1,1) = 7;
X(2,2) = 3;
X(X==0) = NaN;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!