Error on Matlab grading system - Variable y has an incorrect value.
显示 更早的评论
For a MATLAB course, I have to program a code to compute the voltage at three junctions of an electrical system such as the one depicted below:

Following Kirchhoff's First Law, I have designed the following code:
function volt = voltage(V, R)
a = [(R(7)*R(2)+R(1)*R(7)+R(1)*R(2)), -R(1)*R(2), 0; (R(3)*R(8)*R(4)), (R(7)*R(8)*R(4)-R(3)*R(8)*R(4)-R(3)*R(7)*R(4)+R(3)*R(7)*R(8)), (R(3)*R(7)*R(4)); 0, (R(5)*R(6)), (R(8)*R(6)+R(5)*R(8)-R(5)*R(6))]; %3x3 matrix containing the value oh the resistance at each junction as functions of A, B and C
b = V*[(R(7)*R(2)); (R(7)*R(8)*R(4)); (R(8)*R(6))]; %1x3 matrix, product of solving Kirchhoff's firs law for each junction
volt = a\b;
end
When I run it on MATLAB, it works. When I run it on the platform, it works too. But when I try to submit my assignement, the following error appears:
Variable y has an incorrect value. Input was V = 10 and R = [1,2,4,5,13,4,8,1]

What am I doing wrong?
2 个评论
Cris LaPierre
2022-1-6
编辑:Cris LaPierre
2022-1-8
EDIT: Moving OP's comment here
I mean that it worked on my installed version of MATLAB, i.e. that I indroduced some V and R values and I obtained the expected voltage on A, B and C. I attach an image of the question, so you can see how did I obtain those matrixes:

So, when I said that it worked, I meant that I introduce those suggested R values at the end, and I obtanied the desired voltages, both on my installed MATLAB version and on the grading system, but then the errro appeared...
Thanks for replying!
Shaikat Saha
2023-6-19
Can you give me code here, seems interesting
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!