Gistrec

Matlab 3 [Spyder - Python 3.5]

Apr 20th, 2017
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6.  
  7. # Задание 1
  8. A = [[1, 2, 3],
  9.      [3, 5, 6],
  10.      [7, 8, 9]]
  11.    
  12. b = [1, 3, 5]
  13.  
  14. x = np.linalg.tensorsolve(A, b)
  15.  
  16. ver = A*x - b # Проверка не работает 0.о
  17.  
  18. # Задание 2
  19.  
  20. # Создаем матрицу в экселе
  21. # Импортируем матрицу сюда
  22.  
  23. array = np.loadtxt("Z:атлабатрица_5x5.csv", delimiter=';', dtype='int')
  24.  
  25. reverse = array^(-1)
  26.  
  27. np.savetxt("Z:атлабатрица_5x5_new.csv", reverse,  delimiter=';')
  28.  
  29. # Задание 3
  30.  
  31. polynom = [3, 0, 0, 1]
  32. roots = np.roots (polynom)
  33.  
  34. t1 = np.arange(0.0, 5.0, 0.01)
  35.  
  36. plt.figure(1)
  37. plt.subplot(311)
  38. plt.title('First graph')
  39. plt.plot(t1, np.exp(-t1) * np.cos(2*np.pi*t1))
  40.  
  41. plt.figure(1)
  42. plt.subplot(312)
  43. plt.title('Second graph')
  44. plt.plot(t1, np.exp(-t1) * (np.sin(np.pi*t1)))
Advertisement
Add Comment
Please, Sign In to add comment