plot style of 'OutputFcn'=odeplot in odeset

7 vues (au cours des 30 derniers jours)
feynman feynman
feynman feynman le 6 Fév 2024
Modifié(e) : Avni Agrawal le 6 Fév 2024
The following code can plot the solution of the ode with 'odeplot' rather than using 'plot'.
options = odeset('OutputFcn',@odeplot)
ode23(@ode,[0;t],x0,options)
How to change the settings of 'odeplot', for example, how to change the marker, line width etc?
  1 commentaire
Avni Agrawal
Avni Agrawal le 6 Fév 2024
Hi, can you share the whole code?

Connectez-vous pour commenter.

Réponse acceptée

Avni Agrawal
Avni Agrawal le 6 Fév 2024
Hi,
I understand that you want to add styling to your odeplot. Please refer to below code for modifying the settings
% Define options for ode23 with customized odeplot
options = odeset('OutputFcn', @(t,y,flag) odeplot(t,y,flag,'Marker','o','LineWidth',1.5));
ode23(@ode,[0;t],x0,options)
% Modify plot properties
xlabel('Time'); % Change XLabel
ylabel('Solution'); % Change YLabel
title('ODE Solution with Customized odeplot'); % Change Title
% Modify font size
set(gca,'FontSize',12); % Set font size for all axes labels and title
I hope this helps!
  4 commentaires
feynman feynman
feynman feynman le 6 Fév 2024
x0=0;t=1;
options = odeset('OutputFcn', @(t,y,flag) odeplot(t,y,flag,'Marker','.'));
ode23(@(t,x)1,[0;t],x0,options)
Avni Agrawal
Avni Agrawal le 6 Fév 2024
Modifié(e) : Avni Agrawal le 6 Fév 2024
x0 = 0;
t = 1;
options = odeset('OutputFcn', @(t,y,flag) odeplot(t,y,flag));
% Solve the ODE and simultaneously adjust axis font size
ode23(@(t,x)1,[0;t],x0,options);
set(gca,'FontSize',12); % Set font size for all axes labels and title
% Get handle to current axes
ax = gca;
% Find the line object plotted by odeplot
hLine = findobj(ax, 'Type', 'Line');
% Set marker properties for the line
set(hLine, 'Marker', '.', 'MarkerEdgeColor', 'r', 'MarkerSize',10);

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by