I need to solve this problem in Matlab using an iterative me
I need to solve this problem in Matlab using an iterative method
This is what I have already
 T(1)=300;
 T(2)=300;
 T(3)=300;
 T(4)=300;
 R(1)=500+400+100+T(2)-4*T(2);
 R(2)=500+100+T(1)+T(3)-4*T(2);
 R(3)=500+100+T(2)+T(4)-4*T(3);
 R(4)=500+100+T(3)+2*T(4);
Solution
clc;
clear all;
%Define Variables
T1=300; T2=300; T3=300; T4=300;
%Equations and Residuals
R1=[abs(500+400+100+T2-(4*T1))]; R2=[abs(500+100+T1+T3-(4*T2))]; R3=[abs(500+100+T2+T4-(4*T3))]; R4=[abs(500+100+(2*T3)-(4*T4))]; Rt=[R1 R2 R3 R4];
while Rt> 0.1 %Repeat until all residuals converge less than 0.1
Rt(1)=[abs(500+400+100+T2-(4*T1))]; Rt(2)=[abs(500+100+T1+T3-(4*T2))]; Rt(3)=[abs(500+100+T2+T4-(4*T3))]; Rt(4)=[abs(500+100+(2*T3)-(4*T4))];
Rm=max(Rt); %Identify the largest residual (abs(max) vs abs(min))
if Rt(1)==Rm %Find the corresponding index and change the temperature
elseif Rt(2)==Rm
elseif Rt(3)==Rm
else Rt(4)==Rm
end
end
Rt

