How to plot two graphs generated by different files together on the same axis?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a code which accepts one audio file as input. I have to compare the results of 2 audio files on the same graph. I can't use hold on and hold off here as the same code is being run separately. So I give input as the first audio file and get a graph, and then I give second audio file as input and get another graph. How am I supposed to see the result on the same axis in 2 colours?
0 comentarios
Respuestas (1)
dpb
el 28 de Mayo de 2016
Editada: dpb
el 28 de Mayo de 2016
You'll have to modify the function to allow you to plot the second on the existing axes or write a top level function (or do it from the command line) that calls the code first, saves the resulting figure and then calls the second to create the other figure. Then recall the first figure data and add it to the second.
Or, if you can't modify the code, there's always the copyobj alternative--
>> figure,plot(rand(1,100)) % simulates first run of your code, leaves a figure
>> hFig1=gcf; % get its handle
>> hold on % set hold state (not positive the necessary but can't hurt)
>> figure,plot(0.6*rand(1,100)) % now the second execution for second figure
>> hFig2=gcf;
>> hL2=get(gca,'children'); % get the line handle drawn on this second axes
>> figure(1) % switch focus back to Fig 1
>> hL1=copyobj(hL2,gca); % so gca points to Fig 1 axes
>> set(hL1,'color','r') % modify this new line to show up
From this point on, you have hL1,hL2 as the two line handles on Fig 1 which can do whatever with... >>
The above produced the following here...note the red trace is smaller amplitude than the blue; that clearly shows it came from Figure 2 where I multiplied by 0.6.
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!