Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help I keep getting this error. What am I doing wrong? % Matlab script to compute the equivalent resistance of resistors connecte % in series

image text in transcribed

image text in transcribed

image text in transcribed

Help I keep getting this error. What am I doing wrong?

\% Matlab script to compute the equivalent resistance of resistors connecte % in series or parallel where resistance values starts at 100 ohms and eacl \% resistor increases by 100ohms \% input the type of connection, assuming user enters a number 1/2 % input the number of resistors, assuming user enters an integer >=0 n = input('Enter the number of resistors: '); % compute the value of the last resistor in the connection end_value =100+(n1)100; \% create a vector containing the resistor values from 100 to end_value % in steps of 100 i.e 100,200,300,. R=(100:100: end_value ); \% compute the equivalent resistance based on type of connection if ( type ==1)% series connection %R=R1+R2+R3+ % i.e sum of values in the R vector eq_R = sum(R); else % parallel connection %1/R=1/R1+1/R2+1/R3+ % take sum of reciprocal of values in R vector using element by element % operation (./) % equivalent resistance is reciprocal of this sum % you have only computed sum of reciprocal of vector values, so you % have got the answer as 0.03597 you need to take the reciprocal of % this value to get the equivalent resistance in parallel connection eq_R = 1/ sum(1./R); end \% display the equivalent resistance fprintf('Equivalent resistance for % resistors is %f(n; n, eq R ); \% end of script \% input the type of connection, assuming user enters a number 1/2 txee = input ('Enten the txee of sonnestion (1-Secies] 2-Pacallel) inin i % input the number of cesistare. assuming user enter an integer >=a n = input ('Enter the n (9 Function definitions in a script must appear at the end of the file. Move statements to before the function definitions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions