![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/949044/image.png)
Same values's aswer in MATLAB Grader but identified as a mistake.
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/949044/image.png)
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Test Execution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!