- In MatCont, after computing the solution, right-click the solution and export to the workspace. You will typically get a structure with fields like t (time) and x (state matrix).
- Plot both series on the same axes with standard MATLAB commands as shown below
How do I plot two variables on the same graph in matcont?
8 次查看(过去 30 天)
显示 更早的评论
Hi there.
I'm currently using Matcont to simulate the oscillatory behaviour of protein regulation. This is a two variable system in which both mRNA and protein concentration are related two differential equations.
I am using matcont to solve these equations and plot the result. I am unable, however, to plot both the mRNA and protein concentration on a single axis.
Normally if I were using Matlab, I would simply type "hold on", however I cannot see an equivalent function anywhere in the matcont GUI.
I can easily plot either variable as a function of t, but I can't find anything that is able to plot both at the same time.
0 个评论
回答(1 个)
Aashray
2025-8-29,9:07
Yes, you have rightly noticed, in the ‘MatCont’ GUI the plotting is limited to showing one variable at a time versus time. There isn’t a built-in hold on equivalent or overlay option in the GUI itself, so it’s not possible to display mRNA and protein together on the same axis directly within ‘MatCont’.
A simple workaround is to export the computed solution to MATLAB and plot both variables together there. Here is how you can do the same in MATLAB:
% Assuming MatCont exported a struct named "solution"
t = solution.t; % time vector
x = solution.x; % state variables (columns)
% Column 1 = mRNA, Column 2 = protein
figure;
plot(t, x(:,1), 'b-', 'LineWidth', 1.5); hold on;
plot(t, x(:,2), 'r--', 'LineWidth', 1.5);
grid on; xlabel('Time'); ylabel('Concentration');
legend('mRNA','Protein', 'Location','best');
title('mRNA and Protein vs. time (exported from MatCont)');
This should reproduce the “hold on” overlay you are used to, while keeping MatCont for the simulation steps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!