how to find parallel of resistors

264 views (last 30 days)
Kartickeyan V on 18 Jul 2017
Commented: pramod kumar on 23 Jul 2021
Is there any easy function to calculate parallel and series of resistors when i tried its showing error Wrong number of input arguments for obsolete matrix-based syntax.
KSSV on 18 Jul 2017
What you tried show us the code...

Andrei Bobrov on 18 Jul 2017
Edited: Andrei Bobrov on 18 Jul 2017
Z_parallel = 1/sum(1./z); % here z - parallel resistors
Z_series = sum(z); % here z - series resistors
pramod kumar on 23 Jul 2021
is it correct?

Jiji George on 9 Mar 2020
function R = resistors( r1, r2, r3, r4, r5 )
r1 = 100;
r2 = 200;
r3 = 300;
r4 = 400;
r5 = 500;
z = [r1 r2 r3]
R = 1/(sum((1/r1)+(1/r2)+(1/r3)))
end

Nav Riar on 15 Mar 2020
function R = resistors( r1, r2, r3 )
r1 = 100;
r2 = 200;
r3 = 300;
z = [r1 r2 r3]
R = 1/(sum((1/r1)+(1/r2)+(1/r3)))
end

Fabio Freschi on 26 Nov 2020
Edited: Fabio Freschi on 26 Nov 2020
Maybe it's too late for the OP, but for the records, I usually use an anonymous function with multiple inputs
% ananymous parallel function
p = @(varargin)1/sum(1./[varargin{:}]);
% anonymous series funciton
s = @(varargin)sum([varargin{:}]);
% data
r1 = 100;
r2 = 200;
r3 = 300;
r4 = 400;
% call the functions with an arbitrary number of inputs
p(r1,r2)
s(r1,r2)
p(r1,r2,r3)
s(r1,r2,r3)
p(r1,r2,r3,r4)
s(r1,r2,r3,r4)