Cody不断使用SharedVariably1(第11行)断言失败“错误。”无论提交什么代码。
似乎测试套件总是用相同的单元格数组'day temp'''1 1.3'2 1.12''3 17''4 -32''5 13''6 4.4''7 19'。
我已经修复了这个问题,其中测试套件不可见,因为第一个测试套件没有%%
也让我抛出错误。即使答案是我的测试套件也是一样的。
我建议在测试套件中应该有一些有超过一个'运行'的案例,就像“真实世界数据”一样。 For example: clean for an input based on [100 100 9999 9999 100 200 9999 300 500], which has two (not three) 'runs'. (Testing interpolation with nil slope, as in this example, would also have been good to include.)
问题让你出汗,真棒!
这是工作,仍将感激为增强。
函数t = read_and_interp(s)
s = strtrim;
row_num = numel;
计数器= 1;
因为我= 2:row_num
分裂= strsplit ({});
temp1 =分裂(1);
temp2 =分裂(2);
r(柜台)= str2double (temp1);
R(计数器+ 1)= str2double(temp2);
counter = counter + 2;
结束
first_column = r (1:2)
second_column = r(2:2:结束)
如果发现(second_column = = 9999) > = 1
first_column(find(second_column == 9999))= [];
Missed = find(second_column == 9999);
second_column(find(second_column == 9999))= [];
Missed_Value = Interp1(First_Column,Second_column,错过)
second_column = r(2:2:结束);
second_column(find(second_column == 9999))= missed_value;
t = second_column
别的
t = second_column
结束
好问题
当心分裂。
解决方案:
https://github.com/ahmednazir/matlabcody/blob/master/read_and_interp.m.
这让我意识到我需要了解更多关于细胞的信息!
使用以下测试(我自己)时,此解决方案实际上失败。它发生的是由于使用Linspace()// OUT产生的计算精度约0.222 * 1.0E-15。
s = {...
'天Temp'
“1 1.3”
'5 9999'
“9999”
'5 9999'
“9999”
“2 1.12”
' 3 17 '
'4 16'
'5 9999'
“9999”
'7 19'};
t_correct = [1.3 1.264 1.228 1.1920 1.156 1.12 17 16 17 18 19];
断言(isequal (read_and_interp (s), t_correct));
我的独立Matlab功能效果很好 - 但科迪抱怨
"使用SharedVariable1出错(第11行)
断言失败了。”
我不能成为它的头部或尾部。任何帮助吗?
检查测试套房。显示测试套件有一个问题。
很抱歉在此之前所有的错误解决方案,但Cody抛出了错误,而我金宝搏官方网站的Matlab安装没有。