Plot 3D matrix with complex values
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a matrix of complex values (a i +b), with shape 128 * 8 * 121. How can I plot it, please ?
Thank you so much in advance :)
댓글 수: 6
답변 (3개)
Sara James
2019년 10월 21일
As another mentioned previously, use pcolor. Note that since your signal is complex, you will have to take the absolute value first as follows:
fs = 3000; % Sampling frequency (Hz)
t = 0:1/fs:1-1/fs; % Time (sec)
x = [exp(2j*pi*100*cos(2*pi*2*t))+randn(size(t))/100; ...
exp(2j*pi*100*cos(0.5*pi*2*t))+randn(size(t))/100; ...
exp(2j*pi*100*cos(1*pi*2*t))+randn(size(t))/100]'; % Multi-channel signal
[S,F,T] = stft(x,fs,'Window',hamming(128,'periodic'),'OverlapLength',50);
smag = mag2db(abs(S)); % Convert to dB
caxisLims = max(smag(:)) + [-60 0]; % Color axis limits
figure('Name','STFT')
numChannels = size(x,2);
for ii = 1:numChannels
subplot(2,2,ii)
pcolor(T,F,smag(:,:,ii))
xlabel('Time (s)')
ylabel('Frequency (Hz)')
shading flat
hC = colorbar;
hC.Limits = caxisLims;
hC.Label.String = 'Magnitude (dB)';
title(sprintf('Channel %d',ii))
end
sgtitle('Spectrogram')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
