How do I merge 2 figures from 2 different programs in a single figure ?

Hi! Please find attached a file containg code. I got two graphs from two different files and want to merge them into one graph. (so that I can easily compare the graphs)
Could someone tell me how can to merge two graphs from different files?
Thanks :)

1 Commento

Is their any issue?
You can use functions call to paas the plot variables to main script and do the same.

Accedi per commentare.

 Risposta accettata

parag - you could merge the code from the runsub.m and runrub.m files into a single script or function to get something like
function plotsWithAndWithoutAntibodies
close all;
%without antibodies
options = ddeset('RelTol',1e-5,'AbsTol',1e-8,'InitialY',[20,0,0,0]);
sol = dde23('funtryp',14,[0,0,0,0],[0,1500],options);
figure();
plot(sol.x,sol.y(1,:),'r','LineWidth',2);
xlabel('time t');
ylabel('v1(t)');
% with antibodies
options = ddeset('RelTol',1e-5,'AbsTol',1e-8,'InitialY',[20,0,0,0,0]);
sol = dde23('funtryp1',100,[0,0,0,0,0],[0,1500],options);
hold on;
plot(sol.x,sol.y(1,:),'b','LineWidth',2);
You'd probably want to add a legend to distinguish between thet two.
The problem with the two scripts is that each one calls "clear all" and "close all" and so you would lose the plot that has already been drawn.

5 Commenti

Hey! I got two graphs but I want two graphs on same figure.I have attached the figures I got from above code.
I used 'hold on' but its not giving the desired output.
hold on;
plot(sol.x,sol.y(1,:),'r','LineWidth',2);
parag - I made a change to the above code so that the second plot is drawn in blue
hold on;
plot(sol.x,sol.y(1,:),'b','LineWidth',2);
Can you try again? Please ensure that there is only one call to figure in your code.
getting same output with different colors ...
Please post your code and how you are calling it.
thanks :) got the right output

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by