Write a function Mfile called equivres that will compute the

Write a function M-file called equiv_res that will compute the equivalent resistance for a series or parallel combination of an arbitrary number of resistors

Solution

% some Rs
     r=1:4;
% chose comp mode
     mode=input(\'mode parallel [p]/in series [s] < \',\'s\');
% the engine
switch mode
case \'p\'
     res=1./sum(1./r);
case \'s\'
     res=sum(r);
otherwise
     disp(sprintf(\'mode not supported <%s>\',mode));
     return;
end
% the result
     disp(sprintf(\'RESULT (%s) = %g\',mode,res));

Write a function M-file called equiv_res that will compute the equivalent resistance for a series or parallel combination of an arbitrary number of resistorsSol

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site