How to create two graph plots in one, plus scale aside?

1 vue (au cours des 30 derniers jours)
cbentter
cbentter le 4 Mai 2017
Modifié(e) : cbentter le 13 Mai 2017
How to do this figure in MatLab?
Partial code:
M = 256; sigma = 6.0;
h = sin(+2*pi*sigma*log((1-([0:M-1]/M))-0.2));
h(1:37) = 0; h(193:M) = 0;
H= [fft(h) fft(h) fft(h)];
k = ([0:floor(M/2)-1 -floor(M/2):-1]);
S(1,:)=sum(ifft(H(1:M)))/M*ones(1,M);
for n=1:floor(M/2)-1;
W=(1./M)*exp(-n^2*k.^2/(2*M^2))...
.*exp(-2*pi*i*(n*k/M-sign(n) ...
*sigma*log(sigma+abs(n)*k/M)));
W(M/2+1:M-ceil(sigma*M/abs(n))+1)=0;
W = W/sum(W);
S(n+1,:) = ifft(H(n+M+1:n+M+M).* fft(W));
end
figure(10), contour(abs(S),'ShowText','off');
colorbar
Source code and picture, article DOI: 10.1016/j.sigpro.2004.03.015
Title: "Time-local Fourier analysis with a scalable, phase-modulated analyzing function: the S-transform with a complex window"

Réponse acceptée

Santhana Raj
Santhana Raj le 4 Mai 2017
The trick is to use position property in subplot.
figure, subplot('position',[0.1 0.3 0.8 0.7]),contour(abs(S),'ShowText','off');xlim([0 M]);
subplot('position',[0.1 0.1 0.8 0.1]),plot(1:M,h),xlim([0 M]);
you can modify the parameters of position vector to get the exact to what you want.
  1 commentaire
cbentter
cbentter le 4 Mai 2017
Thank you for your support. Great solution!

Connectez-vous pour commenter.

Plus de réponses (1)

cbentter
cbentter le 4 Mai 2017
Similar figure and complete soluction basead on 'Santhana Raj' answer
len = 512;
t(1:len) = [0:0.25:127.75];
h(1:128) = 0;
% h = zeros(1,512);
h(129:512) = exp(-4*[0:383]/256).*sin(2*pi*[0:383]*20.4/512);
h(157:512) = h(157:512)+ exp(-5*[0:355]/256).*sin(2*pi*[0:355]*30.7/512);
h(269:512) = h(269:512) + exp(-4*[0:243]/256).*sin(2*pi*[0:243]*25.3/512);
h(397:512) = h(397:512) + exp(-4*[0:115]/256).*sin(2*pi*[0:115]*15.6/512);
figure(10), plot(h), xlim([0 len]);
xlabel('Sample Point Number'), ylabel('Amplitude');
M = 512; H = [fft(h) fft(h)];
g = 1.0; gf = 0.5;
gb = ((pi-4)*gf+sqrt((8*pi+3*pi^2)*gf- ...
(4*pi^2-8*pi)*g))/2/(pi-2);
t = [[0:floor(M/2)-1]/gb [-floor(M/2):-1]/gf];
W = [1 zeros(1,M-1)];
for m=0:floor(M/4)-1;
STR(m+1,:) = ifft(H(m+1:m+M) .* W);
w = abs(m+1)/sqrt(2.*pi)*2/(gb+gf) ...
* exp(-(m+1)^2*t.^2/(2*M^2));
W = fft(w/sum(w));
end
figure(11), contourf(abs(STR),'ShowText','off');
ylabel('Frequency (Hz)');
% shading interp;
colormap(gray)
colormap(flipud(colormap))
shading flat;
colorbar
figure(12)
% subplot(2,1,1),
subplot('position',[0.1 0.45 0.77 0.5]),
contourf(abs(STR),'ShowText','off');
colormap(gray)
colormap(flipud(colormap))
shading flat;
colorbar
colorbar('position',[0.9 0.15 0.032 0.8]);
% subplot(2,1,2),
subplot('position',[0.1 0.15 0.77 0.2]),
plot(h), xlim([0 len]);
xlabel('Sample Point Number'), ylabel('Amplitude');
reference: PII. S1064827500369803
  2 commentaires
KSSV
KSSV le 5 Mai 2017
@cbentter, it is better to give credits to the user who have helped you. I prefer accepting Santha Raj's answer rather then own-self.
cbentter
cbentter le 13 Mai 2017
Modifié(e) : cbentter le 13 Mai 2017
See below Santhana Raj comment.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by