フィルターのクリア

Same values's aswer in MATLAB Grader but identified as a mistake.

3 ビュー (過去 30 日間)
adam soker
adam soker 2022 年 4 月 1 日
編集済み: Cris LaPierre 2022 年 4 月 4 日
The references solution for 'f' is:
a = 4
m = 3
b = -3
l = 6
C1 = -0.42
C2 = -4.00
C3 = -2.07
C4 = 0.30
t = -10:0.1:10;
s = t.*(t>=0 & t<=1);
sa = (t-a).*((t-a)>=0 & (t-a)<=1);
sm = m.*s;
sb = (t/b).*((t/b)>=0 & (t/b)<=1);
sdr = (l-t).*((l-t)>=0 & (l-t)<=1);
f = C1*sa + C2*sm + C3*sb + C4*sdr;
The student's solution is:
f = ((-0.42)*t+1.68).*(t>=4 & t<=5)-12*t.*(t>=0 & t<=1) + (0.69)*t.*(t<=0 & t>=(-3))+(1.8-0.3*t).*(t<=6 & t>=5);
The solutions should be the same. But when them there is a size 1.6653e-16 error, so the student's answer is not accepted.

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 4 月 1 日
編集済み: Cris LaPierre 2022 年 4 月 4 日
How have you set up your assessment test? Are you using the Variable Equals Reference Solution test or a MATLAB Code test type? If MATLAB Code, have you incorporated tolerances into your equality check?
When I test the code you have shared in Grader, the learner solution's value of f is marked correct.
I used the drop down test "Variable equals reference solution" and entered f as the "variable name you want to compare". This automatically applies a +/- 0.1% relative or +/- 0.0001 absolute tolerance to the solution. This means a difference of 1.6653e-16 is considered equal.
  1 件のコメント
Cris LaPierre
Cris LaPierre 2022 年 4 月 1 日
Here is a picture of how I set up the assessment test.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTest Execution についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by