Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.22 KB | None | 0 0
  1. % [b] Using the build in function for polynomial root computation we verify
  2. % the roots that we got in section [a]:
  3. r= roots([1,0,0,0,-16]);
  4. disp(r);
  5. % [c] By making a figure in the complex plan,that connects all four roots that we optain in [b] in a loop and which
  6. % goes from a root which has the real part equal to zero to a root that has
  7. % the imaginary part equal to zero or vice versa we optain a plot which shows
  8. % that the four roots are positioned on the vertices of a square:
  9. plot(([r(1),r(2),r(4),r(3),r(1)]),'-o');
  10. % plots the roots in the right order (for example could also be [r(2),r(4),r(3),r(1),r(2)]) to make a square and adds a small
  11. % circle around each root
  12. grid;
  13. % colours the background of the plot with squares with side of length of
  14. % one unit
  15. title('Argand diagram');
  16. % labels the diagriam
  17. xlabel('Real axis');
  18. % labels the x axis of the diagram
  19. ylabel('Imaginary axis');
  20. % labels the y axis of the diagram
  21. % [d] To get the length of a side of the square that we got in the plot of [c] we need
  22. % to calculate the modulus of the complex number that we get taking the difference of two consecutive complex
  23. % numbers that were used to obtain the plot.
  24. abs(r(1)-r(2));
  25. % could also be abs(r(2)-r(4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement