Error on Matlab grading system - Variable y has an incorrect value.

21 visualizaciones (últimos 30 días)
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 comentarios
Cris LaPierre
Cris LaPierre el 6 de En. de 2022
Editada: Cris LaPierre el 8 de En. de 2022
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
Shaikat Saha el 19 de Jun. de 2023
Can you give me code here, seems interesting

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 6 de En. de 2022
I took a new look and decided to back out your equations to see what is happening. My best guess is that you are inconsistent in defining your current directions.
My recommendation is to draw the current direction through each resistor, and then write your equations assuming that direction.
For example, for node A, the current through R7 is defined as leaving A and going into B:
However, in backing out your equation for node B, you define the current as heading from B to A by doing one of the following:
or
Put another way, write an equation for each resistor current, and then use that same equation everywhere. So here, that means for R7, my equation defines the current direction as going from A to B:
That means for node A, the current is leaving A, so subtract this equation:
It also means that for node B, the current is enterring B, so add this equation:
  2 comentarios
Pablo Rodríguez Suárez
Pablo Rodríguez Suárez el 6 de En. de 2022
It finally worked! I tried to reverse the equations for each junction, but I did it wrong. Thank you so much!
Shaikat Saha
Shaikat Saha el 19 de Jun. de 2023
Can you give the code here? Seems interesting

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by