Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. % Networks and Systems Final Project by:
  2. % Group #1
  3. % Justin Richards B00701873
  4. % William Day B00850918
  5. % Calum MacPherson B00850922
  6.  
  7. % Asumptions Made:
  8.  
  9. % Each new branch will be in parallel with the previous branch.
  10.  
  11. % The bottom portion of each branch will be a 1K ohm resistor to prevent short circuiting, and simplify circuit.
  12.  
  13. % The polarity of voltage and current sources face from the lower node (k
  14. % value) to the higher (k value) node , inputs should reflect the opposite
  15. % direction with a negative value.
  16.  
  17.  
  18. clear
  19. f=0 %initialize frequency
  20. nodes = input ('Enter number of nodes in the circuit: ') %insert number of nodes
  21. cct = zeros(nodes-1,5) %create array for component variables
  22. Z= zeros(length(f)) %create array for impedances with frequencies
  23. disp ('The number of nodes entered is:')
  24. disp (nodes)
  25. for i=1:nodes-1 % Loop to determine components between each node
  26.  
  27. Ikey = ['Are there any independant current sources between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
  28. Currentsource = input(Ikey) %determine and insert values (if any) of current sources into array.
  29. if Currentsource == 1
  30. cct(i,1)=input('Input the net current value (in amps) of the combined current source(s) between the nodes: ')
  31. end
  32.  
  33. Vkey = ['Are there any independant voltage sources between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
  34. voltagesource = input(Vkey) %determine and insert values (if any) of voltage sources into array.
  35. if voltagesource == 1
  36. cct(i,2) = input('Input the net voltage value (in volts) of the combined voltage source(s) between the nodes: ')
  37. end
  38.  
  39. Ckey = ['Are there any capacitors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"): ']
  40. cap = input(Ckey) %determine and insert values (if any) of the capacitors into array.
  41. if cap == 1
  42. cct(i,3) = input('Input the net capacitance value (in farads) of the combined capacitor(s) between the nodes: ')
  43.  
  44.  
  45. end
  46.  
  47. Lkey = ['Are there any inductors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"):']
  48. ind = input(Lkey) %determine and insert values (if any) of the inductors into array.
  49. if ind == 1
  50. cct(i,4)= input('Input the net inductance value (in Henrys) of the combined inductor(s) between the nodes: ')
  51.  
  52. end
  53.  
  54. Rkey = ['Are there any resistors between nodes ',num2str(i),' and ',num2str(i+1),' ? (input 1 for "yes" and 0 for "no"): ']
  55. res = input(Rkey) %determine and insert values (if any) of the resistors into array.
  56. if res == 1
  57. cct(i,5) = input('Input the net resistance value (in ohms) of the resistor(s) between the nodes: ')
  58. end
  59. end
  60.  
  61. f=input('Please enter the range of frequencies: (please use square brackets in [#:#] form):')
  62. 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)
  63. for l=1:length(f)
  64. Z(k,l)=j*(2*pi*f(l)*cct(k,4))-(j*(1/2*pi*f(l)*cct(k,3)))+cct(k,5)
  65. end
  66. end
  67. for o=1:nodes %solve system of equations of voltage at each node for various frequency values.
  68. for p=1:length(f)
  69. eqn(o) = (v1-v2)/Z(k,p) == v1/1000;
  70. eqn(1) = ()
  71.  
  72.  
  73.  
  74. nodevolt= zeros(nodes,length(f))
  75. end
  76. %plot each node's voltage with respect to the range of the frequency
  77. xlabel('Frequency (Hz)');
  78. ylabel('Voltage in V');
  79. title('Maximum Output Voltage vs Frequency')
  80. legend('Output Voltage vs Frequency','Input Voltage vs Frequency');
  81. set(gca, 'FontName', 'Times New Roman','FontSize', 14);
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement