How do I plot two variables on the same graph in matcont?

8 Ansichten (letzte 30 Tage)
Patric Boardman
Patric Boardman am 15 Jan. 2021
Beantwortet: Aashray am 29 Aug. 2025
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.

Antworten (1)

Aashray
Aashray am 29 Aug. 2025
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:
  1. 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).
  2. Plot both series on the same axes with standard MATLAB commands as shown below
% 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.

Kategorien

Mehr zu Graphics finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by