问题17.找到所有小于0或大于10的元素,并用NAN代替它们
解决方案统计
问题评论
-
14条评论
this is a poorly posed problem. There are no numbers that are both less than zero and greater than 10.
Just had the same thought as James Ross...
Fixed the wording to reflect this. Thanks for the comments.
come on wth is this problem i got wrong when i check my answer is true
谁可以给我解释一下这个?
clearup =@(lb,x)Interp1([[lb 10],[lb 10],x); x = [5 17 -20 99 3.4 2 8 -6]; y_correct = [5 nan nan nan nan 3.4 2 8 nan];
[isequalwithequalnans(清理(1,x),y_correct),isequalwithequalnans(清理(0,x),y_correct)]
that is, if i set the lower bound (lb) of the interpolation to 1 it passes the test code but if I set it to zero it fails with the same output!?!
结果中的3.4在两个插值中不相同(DIFF = 4.440892098500626E-16)。它很小,但足以使均等测试失败。
16 is the first non-regexp-solution!
好问题
我对第一次测试的断言失败,但第二个测试是有益的 - '我不明白。你能帮助我吗 ?
More usefull than I thougth
有用的基础知识
hay
很酷的问题!
GOOG
解决方案Comments
-
1条评论
tHIS PROBLEM IS FANTASTIC!
-
1条评论
功能y =清理(x)
y = x;
l =长度(y);
for i=1:L
if (y(i)<0)|(y(i)>10)
y(i)=NaN;
结尾
结尾
结尾
-
1条评论
this hasn't been fixed?
-
1条评论
好的
-
1条评论
l
-
1条评论
我减少我的代码大小的帮助在这个页面。
http://matlabtricks.com/post-16/the-background-of-cody-金宝搏官方网站solutions-having-extremely-low size。
此外,领先的解决方案是骗子。
-
1条评论
very easy
-
1条评论
Nicely done!
-
2条评论
我该如何使其短?
您可以删除1:
i= 1:length(x)
和
x(i)<0 |X(i)> 10
另外,最好使用Numel而不是长度。
-
1条评论
第一个无琐的人,学到了一个新技巧
-
2条评论
关于如何减少尺寸的任何建议吗?
x(x < 0 | x > 10) = NaN // use this it will reduce code size
-
3条评论
-
1条评论
这称为逻辑索引
-
1条评论
好的
-
1条评论
无需结肠操作员...
-
6条评论
How does the cleanup function work? I did not find a good explanation, but would be interested in how it works.
我不明白这种尺寸是怎么可能的。甚至像y = x+1一样简单;根据“关于Cody”页面的尺寸12!对我来说有点谜...
因此,我在这里谷歌搜索并在这里找到了一个解释,http://matlabtricks.com/post-16/the-background-of-cody-solutions-having-sol金宝搏官方网站utions-having-esptremelly-low size
所以这确实是一种作弊?我想知道为什么允许它...
我也是。想知道,我的意思是。
感谢您提供极低尺寸解决方案的解决方案
具有讽刺意味。尺寸度量旨在创建最优雅的解决方案。金宝搏官方网站同时,这种方式更有趣。
-
1条评论
Straight forward with a for loop. Could definitely be improved considering good code doesn't use loops.
-
1条评论
检查内置功能“ REGEXP”
-
1条评论
该代码有效,但其得分为51,那不好。...任何人都可以改进它,我会感激不尽。
-
1条评论
are you ok?
-
1条评论
there can be no elements with <0 AND >10. The problem statement should say <0 OR >10.
-
2条评论
我不明白为什么出错?O.O
您将需要一个循环浏览X的每个元素才能完成此操作...一个非常糟糕的主意。
-
1条评论
嗯
-
2条评论
功能y =清理(x)
x = [5 17 -20 99 3.4 2 8 -6]
for i=1:8
if(x(i)<0 || x(i)> 10)
y(i)=NaN;
别的
y(i)= x(i);
结尾
结尾
Can anybody tell what is wrong with this code so that it is not clearing test 2.
Check this:Solution 181284.
X是输入矩阵,它将变化而不是上述程序中的定义。
-
1条评论
如果没有一种伊斯兰教的方式?
-
2条评论
杰出的
impressive!
-
1条评论
It is working when I try!?
Problem Recent Solvers14198
建议的问题
7676求解器
549 Solvers
Celsius to Fahrenheit converter
480个求解器
465 Solvers
441 Solvers