How to subplot a graph returned by MATLAB function for which there is no option to take the figure handle as input nor can it return a handle as output?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to plot the output of cwt() to a subplot so that I can compare the result with other graphs next to each other. However, to the best of my understanding, cwt() doesn't take handles as input for me to pass a subplot handle. Nor does it return any handle. I tried a couple of approaches without much success. Ideally, I would like the approach to work something like:
Fs=100; t=0:1/Fs:10; y=sin(t); %create a simple sinusoidal signal
figure;
subplot(2,1,1);plot(t,Fs) %plot the sinusoidal signal in suplot 211
subplot(2,1,2);cwt(signal,Fs); %plot the output of cwt() in subplot of 212
But, that doesn't work. cwt() merely replaces the subplots and simply plots like normal.
I have tried other approaches such as copyobj():
figure(1); cwt(signal,Fs); ax1=gca
ax2=figure(2);
copyobj(ax1,ax2);
This works well in copying the figure from figure 1 to figure 2, but when i try a similar approach to copy figure 1 to subplot in figure 2, it fails giving me the error "Axes cannot be a child of Axes". Below the corresponding code:
figure(1); cwt(signal,Fs); ax1=gca
figure(2);ax2=subplot(2,1,1);
copyobj(ax1,ax2);
Any help?
1 commentaire
Walter Roberson
le 9 Avr 2018
cwt() without an output will always clear the complete current figure.
Réponses (2)
Prajit T R
le 9 Avr 2018
Hi Hari
Here, cwt is being plotted as a subplot. Hence this should be possible in your case as well. Try to modify the code that you would find on the link to suit your requirement.
Hope this helps.
Cheers
0 commentaires
Jan Rusz
le 16 Fév 2021
You have to copy ax1 to figure object, not to axes object:
fig2=figure(2);
copyobj(ax1,fig2);
0 commentaires
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!