There is a vector which i have done stft transform on it in python and i got an image as output. I am trying to save it in a directory but as it has three parameters(f, t, Zxx), i don't know how to save it. thanks if anyone can help me to save it thanks if anyone can help me to save it. my code is as below
#Importing the Libraries-----------------------------------------------------------------------
from scipy import signal
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
#Importing the Data----------------------------------------------------------------------------
train_data = loadmat('D:\\thesis\\new data
preproceses\\A_train_segmented_onehot\\Data_train_3ch_A_train.mat')
train_data = train_data.get('Data_train_3ch_A_train')
#Defiening the parameters----------------------------------------------------------------------
fs = 10e3
N = 1e5
amp = 2 * np.sqrt(2)
#Calculate STFT---------------------------------------------------------------------------------
f, t, Zxx = signal.stft(train_data[0], fs, nperseg=20)
#Plot Image ------------------------------------------------------------------------------------
plt.pcolormesh(t, f, np.abs(Zxx), vmin=0, vmax=amp, shading='gouraud')
plt.title('STFT Magnitude')
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()