Conversion to cell from double is not possible.

I am trying to solve delay logistic equation with multiple delay terms but for finding delayed states i am getting error and my error is
"Conversion to cell from double is not possible."
g = @(t, y, Z, par) par(1) * y * (1 - sum(par(2:end) .* Z));
tau = [1, 1.5,2,2.5,3]; % Array of different delays
par = [1.5, 0.1,0.2,0.3,0.4,0.5];
this is my equation
and I am getting error here in this part
%% Calculate delayed states for multiple delays
x_d = cell(length(tau), 1);
for k = 1:length(tau)
x_d(k) = deval(sol, t_t - tau(k));
end

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 28일

0 개 추천

You need to use curly brackets, {}
%% Calculate delayed states for multiple delays
x_d = cell(length(tau), 1);
for k = 1:length(tau)
% v v
x_d{k} = deval(sol, t_t - tau(k));
end

댓글 수: 5

Thank you its working
Now i am getting error in this next part and the error is "Operator '.*' is not supported for operands of type 'cell'."
x_dn = cell(size(x_d));
for k = 1:length(x_d)
x_dn(k) = x_d(k) + eps * randn(size(x_d(k))) .* x_d(k);
end
Dyuman Joshi
Dyuman Joshi 2023년 11월 28일
편집: Dyuman Joshi 2023년 11월 28일
Again, use curly brackets for cell arrays.
x_dn = cell(size(x_d));
for k = 1:length(x_d)
% v v v v v v v v
x_dn{k} = x_d{k} + eps * randn(size(x_d{k})) .* x_d{k};
end
Also, you can combine the for loops for x_d and x_dn.
Muhammad
Muhammad 2023년 11월 28일
Thank you so much for help
Matt J
Matt J 2023년 11월 28일
편집: Matt J 2023년 11월 28일
@Muhammad Please Accept-click the answer to indicate that it worked.
Thanks @Matt J.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2023년 11월 28일

편집:

2023년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by