Matlab grader not working

20 ビュー (過去 30 日間)
Luca Formaggia
Luca Formaggia 2021 年 11 月 17 日
コメント済み: Sachin Kelkar 2023 年 2 月 6 日
I have setup a test in Matlab grader, my reference solution contains a variable called finalvalue (you find the code at the end of this message). I want to assess the student on the value of finalvalue. So I am using in the assessment panel the option to verify the value of final value. I test the reference code and I obtain
Unable to resolve the name referenceVariables.finalvalue. Error in Test1
I have also tried to do the check explicitely with
xReference = referenceVariables.finalvalue;
assessVariableEqual('finalvalue', xReference);
with no avail!! It seems that the grader is unable to find the variable (I have event tried to change the variable name.... same error).
Her the code (which workd perfectly, it produces the right plot and the right value of finalvalue (rk4.m is a script which is provided in the File Referenced section and is a simple runge kutta).
Could you explain me what I am doing wrong?
Here is the code:
clear all
close all
%%
mu=10;
f = @ (t,y) [y(2);mu*(1-y(1)^2)*y(2)-y(1)];
y0=[0;10];
tspan=[0,100];
%%
h=0.01;
Nh=(tspan(2)-tspan(1))/h;
[t,u]=rk4(f,tspan,y0,Nh);
%
plot(t,u(:,1),t,u(:,2));
figure
plot(u(:,1),u(:,2));
%%
finalvalue=u(end,2);
finalvalue

採用された回答

Luca Formaggia
Luca Formaggia 2021 年 11 月 17 日
Sorted it out! It was the
clear all
at the beginning that was causing the problem. After taking it out everything works as expected.
  1 件のコメント
Sachin Kelkar
Sachin Kelkar 2023 年 2 月 6 日
I'm a TA and I spent 1hr looking for bugs, this fixed it. thank you very much!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by