필터 지우기
필터 지우기

Operator '*' is not supported for operands of type 'function_handle'.

조회 수: 19 (최근 30일)
nune pratyusha
nune pratyusha 2022년 5월 20일
편집: Torsten 2022년 5월 20일
clc; clear all;
format compact; format long e;
set(0,'defaultaxesfontsize',16.5,'defaultaxeslinewidth',0.8,...
'defaultlinelinewidth',2.0,'defaultpatchlinewidth',2.7,...
'defaultaxesfontweight','Bold')
b=0.4;c=11;d=6;e=130;f=10;m=1;
global a
brange = 5:1:12.2;
k = 0; tspan = 0:1e-1:70;
xmax = [];
for a = brange
a
j = 1; k = k + 1;
f = @(t,x) [a*x(2)+(0.2+0.2.*abs(x(4))).*x(3);b*((x(4).^2)-13).*x(3)-c*x(2);-d*x(1)-e*x(2)-f*x(3);(x(3).^2)-x(4).^2];
x0 = [0 0 1 1];
[t,x] = ode15s(f,tspan,x0);
count = find(t>10);
x = x(count,:);
j = 1;
n = length(x(:,1));
for i=2 : n-1
if (x(i-1,1)+eps) < x(i,1) && x(i,1) > (x(i+1,1)+eps)
xmax(k,j)=x(i,1);
j=j+1;
end
end
if j>1
plot(a,xmax(k,1:j-1),'k.');
end
hold on;
index(k)=j-1;
end
xlabel('Bifurcation parameter b');
ylabel('x max');
title('Bifurcation diagram for b');
error is like:
a =
5
a =
6
Operator '*' is not supported for operands of type 'function_handle'.
Error in double_mem_bif>@(t,x)[a*x(2)+(0.2+0.2.*abs(x(4))).*x(3);b*((x(4).^2)-13).*x(3)-c*x(2);-d*x(1)-e*x(2)-f*x(3);(x(3).^2)-x(4).^2] (line 16)
f = @(t,x) [a*x(2)+(0.2+0.2.*abs(x(4))).*x(3);b*((x(4).^2)-13).*x(3)-c*x(2);-d*x(1)-e*x(2)-f*x(3);(x(3).^2)-x(4).^2];
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 152)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in double_mem_bif (line 18)
[t,x] = ode15s(f,tspan,x0);
>>

답변 (1개)

Steven Lord
Steven Lord 2022년 5월 20일
b=0.4;c=11;d=6;e=130;f=10;m=1;
% ...
f = @(t,x) [a*x(2)+(0.2+0.2.*abs(x(4))).*x(3);b*((x(4).^2)-13).*x(3)-c*x(2);-d*x(1)-e*x(2)-f*x(3);(x(3).^2)-x(4).^2];
Change the name of your anonymous function so it doesn't overwrite the constant f you defined above. Use that new name when you call ode15s.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by