フィルターのクリア

Please, I want help in adjusting the quality of the figure surface shape as in the attached picture (as in color, and colored lines in the horizontal plane)

1 回表示 (過去 30 日間)
options = odeset('RelTol',1e-6,'Stats','on');
% initial conditions
Xo = [0.5; 0.7; 2];
% choose parameters t and a
tspan = linspace(0,100);
a_vec = 0.01 : 0.005 : 0.03;
% ease the coding and readability
num_t = numel(tspan);
num_a = numel(a_vec);
num_x = numel(Xo);
% allocate output
X = zeros(num_t,num_x,num_a);
for idx = 1:num_a
% Collect all X values into a 3D matrix. Additional parameters to
% TestFunction can be added after ode45 options
[t,X(:,:,idx)] = ode45(@TestFunction,tspan,Xo,options,a_vec(idx));
end
% make sure we have the proper dimmensions before calling surf
plot_t = repmat(t,1,num_a);
plot_a = repmat(a_vec,num_t,1);
plot_x = squeeze(X(:,1,:));
% create the surf plot
figure
surf(plot_t,plot_a,plot_x)
xlabel('t values')
ylabel('a values')
zlabel('x values')
grid on
function [dx_dt]= TestFunction(~,x,a)
r=0.05; k=0.1; %a=0.02;
m=0.02; b=0.2; eta=0.06; h=1;
dx_dt(1)=r.*x(1).*(1-(x(1)./k))-a.*x(1).*x(3)+x(3).*eta;
dx_dt(2)=a.*x(1).*x(3)-m.*x(2)-b.*x(2)+h.*eta;
dx_dt(3)=b.*x(2)-eta.*x(3)-r.*x(1);
dx_dt = dx_dt';
end
  3 件のコメント
T K
T K 2022 年 12 月 26 日
options = odeset('RelTol',1e-6,'Stats','on');
% initial conditions
Xo = [0.5; 0.7; 2];
% choose parameters t and a
tspan = linspace(0,100);
a_vec = 0.01 : 0.005 : 0.03;
% ease the coding and readability
num_t = numel(tspan);
num_a = numel(a_vec);
num_x = numel(Xo);
% allocate output
X = zeros(num_t,num_x,num_a);
for idx = 1:num_a
% Collect all X values into a 3D matrix. Additional parameters to
% TestFunction can be added after ode45 options
[t,X(:,:,idx)] = ode45(@TestFunction,tspan,Xo,options,a_vec(idx));
end
% make sure we have the proper dimmensions before calling surf
plot_t = repmat(t,1,num_a);
plot_a = repmat(a_vec,num_t,1);
plot_x = squeeze(X(:,1,:));
% create the surf plot
figure
surf(plot_t,plot_a,plot_x)
xlabel('t values')
ylabel('a values')
zlabel('x values')
grid on
function [dx_dt]= TestFunction(~,x,a)
r=0.05; k=0.1; %a=0.02;
m=0.02; b=0.2; eta=0.06; h=1;
dx_dt(1)=r.*x(1).*(1-(x(1)./k))-a.*x(1).*x(3)+x(3).*eta;
dx_dt(2)=a.*x(1).*x(3)-m.*x(2)-b.*x(2)+h.*eta;
dx_dt(3)=b.*x(2)-eta.*x(3)-r.*x(1);
dx_dt = dx_dt';
end
T K
T K 2022 年 12 月 27 日
編集済み: T K 2022 年 12 月 27 日
@Walter Roberson The code mentioned above

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 28 日
移動済み: Walter Roberson 2022 年 12 月 29 日
It is not clear to me what changes you want.
If you want a plot that is smoother along the a axis then you ned to use more a_vec values.
options = odeset('RelTol',1e-6,'Stats','on');
% initial conditions
Xo = [0.5; 0.7; 2];
% choose parameters t and a
tspan = linspace(0,100);
a_vec = 0.01 : 0.005 : 0.03;
% ease the coding and readability
num_t = numel(tspan);
num_a = numel(a_vec);
num_x = numel(Xo);
% allocate output
X = zeros(num_t,num_x,num_a);
for idx = 1:num_a
% Collect all X values into a 3D matrix. Additional parameters to
% TestFunction can be added after ode45 options
[t,X(:,:,idx)] = ode45(@TestFunction,tspan,Xo,options,a_vec(idx));
end
34 successful steps 0 failed attempts 205 function evaluations 34 successful steps 0 failed attempts 205 function evaluations 34 successful steps 0 failed attempts 205 function evaluations 34 successful steps 0 failed attempts 205 function evaluations 34 successful steps 0 failed attempts 205 function evaluations
% make sure we have the proper dimmensions before calling surf
plot_t = repmat(t,1,num_a);
plot_a = repmat(a_vec,num_t,1);
plot_x = squeeze(X(:,1,:));
% create the surf plot
figure
surf(plot_t,plot_a,plot_x)
xlabel('t values')
ylabel('a values')
zlabel('x values')
grid on
%adjust color
colormap(jet)
%another way of adjusting color
lighting GOURAUD
shading interp
%colored lines on the horizontal plane
ax = gca;
ax.XAxis.Color = 'b';
ax.YAxis.Color = 'r';
%but maybe this is what you mean about colored lines...
figure();
surfc(plot_t,plot_a,plot_x)
xlabel('t values')
ylabel('a values')
zlabel('x values')
grid on
function [dx_dt]= TestFunction(~,x,a)
r=0.05; k=0.1; %a=0.02;
m=0.02; b=0.2; eta=0.06; h=1;
dx_dt(1)=r.*x(1).*(1-(x(1)./k))-a.*x(1).*x(3)+x(3).*eta;
dx_dt(2)=a.*x(1).*x(3)-m.*x(2)-b.*x(2)+h.*eta;
dx_dt(3)=b.*x(2)-eta.*x(3)-r.*x(1);
dx_dt = dx_dt';
end
  1 件のコメント
T K
T K 2022 年 12 月 29 日
移動済み: Walter Roberson 2022 年 12 月 29 日
Thank you very much for the tip, yes it has been clarified

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by