Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Networks and Systems Final Project by:
- % Group #1
- % Justin Richards B00701873
- % William Day B00850918
- % Calum MacPherson B00850922
- % Asumptions Made:
- % Each new branch will be in parallel with the previous branch.
- % The bottom portion of each branch will be a 1K ohm resistor to prevent short circuiting, and simplify circuit.
- % The polarity of voltage and current sources face from the lower node (k
- % value) to the higher (k value) node , inputs should reflect the opposite
- % direction with a negative value.
- clear
- f=0 %initialize frequency
- nodes = input ('Enter number of nodes in the circuit: ') %insert number of nodes
- cct = zeros(nodes-1,5) %create array for component variables
- Z= zeros(length(f)) %create array for impedances with frequencies
- disp ('The number of nodes entered is:')
- disp (nodes)
- for i=1:nodes-1 % Loop to determine components between each node
- Ikey = ['Are there any independant current sources between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
- Currentsource = input(Ikey) %determine and insert values (if any) of current sources into array.
- if Currentsource == 1
- cct(i,1)=input('Input the net current value (in amps) of the combined current source(s) between the nodes: ')
- end
- Vkey = ['Are there any independant voltage sources between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
- voltagesource = input(Vkey) %determine and insert values (if any) of voltage sources into array.
- if voltagesource == 1
- cct(i,2) = input('Input the net voltage value (in volts) of the combined voltage source(s) between the nodes: ')
- end
- Ckey = ['Are there any capacitors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"): ']
- cap = input(Ckey) %determine and insert values (if any) of the capacitors into array.
- if cap == 1
- cct(i,3) = input('Input the net capacitance value (in farads) of the combined capacitor(s) between the nodes: ')
- end
- Lkey = ['Are there any inductors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
- ind = input(Lkey) %determine and insert values (if any) of the inductors into array.
- if ind == 1
- cct(i,4)= input('Input the net inductance value (in Henrys) of the combined inductor(s) between the nodes: ')
- end
- Rkey = ['Are there any resistors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"): ']
- res = input(Rkey) %determine and insert values (if any) of the resistors into array.
- if res == 1
- cct(i,5) = input('Input the net resistance value (in ohms) of the resistor(s) between the nodes: ')
- end
- end
- f=input('Please enter the range of frequencies: (please use square brackets in [#:#] form):')
- for k=1:nodes-1 %determine values of impedances between nodes with respect to the range of frequencies, and insert into array. (1 unit step)
- for l=1:length(f)
- Z(k,l)=j*(2*pi*f(l)*cct(k,4))-(j*(1/2*pi*f(l)*cct(k,3)))+cct(k,5)
- end
- end
- for o=1:nodes %solve system of equations of voltage at each node for various frequency values.
- for p=1:length(f)
- eqn(o) = (v1-v2)/Z(k,p) == v1/1000;
- eqn(1) = ()
- nodevolt= zeros(nodes,length(f))
- end
- %plot each node's voltage with respect to the range of the frequency
- xlabel('Frequency (Hz)');
- ylabel('Voltage in V');
- title('Maximum Output Voltage vs Frequency')
- legend('Output Voltage vs Frequency','Input Voltage vs Frequency');
- set(gca, 'FontName', 'Times New Roman','FontSize', 14);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement