MATLAB: How to use “for” function for looping with 3 variables

for loopMATLAB

Hello, I want to ask about how to use "for" function for calculating each iteration with 3 different variables. I want to calculate Wheston Bridge using different 3 variables. Here my code. Thank you
R1 = 100;
R2 = [200 : 1 : 300];
R3 = [250 : 1 : 350];
R4 = [300 : 1 : 400];
Vin = 10;
kk = 1;
for i = 1:length(R2)
for j = 1:length(R3)
for k = 1:length(R4)
Rs(kk) = (R2(i)./(R2(i)+R1))-(R4(k)./(R3(j)+R4(k)));
Vo(kk) = Vin*((R2(i)./(R2(i)+R1))-(R4(k)./(R3(j)+R4(k))));
kk = kk +1;
end
end
end

Best Answer

No need of for-loops:
[a,b,c]=meshgrid(R2,R3,R4);
Rs = a./(a+R1)-c./(b+c);
Vo = Vin*Rs;