MATLAB Answers


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

Asked by parag gupta on 18 Jul 2019
Latest activity Commented on by parag gupta on 19 Jul 2019
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 Comment

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

Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 18 Jul 2019
Edited by Geoff Hayes
on 18 Jul 2019
 Accepted Answer

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);
xlabel('time 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;
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.


getting same output with different colors ...
Please post your code and how you are calling it.
thanks :) got the right output

Sign in to comment.