no sinusoidal perturbation, the initial condition does not appear in the result, I could not figure out the problem.

1 次查看(过去 30 天)
I have problem that the initial condition fr = 0.05 +0.0001*(1+sin(k*x));fl,.. and the others did not show any sinusoidal perturbation. If I wrote the initial condition asfr = @(x) 0.05 +0.0001*(1+sin(k*x)); the code works. However if I delete @(x) d
oes not work.

回答(1 个)

SAI SRUJAN
SAI SRUJAN 2023-10-4
Hi lulu,
Based on my comprehension of the question,the initial condition "fr = 0.05 +0.0001*(1+sin(k*x))" is not showing any sinusoidal perturbation,whereas the initial condition "fr = @(x) 0.05 +0.0001*(1+sin(k*x))" works as expected.
The initial condition "fr = 0.05 +0.0001*(1+sin(k*x))" creates a 1x101 double vector.The following errors have been encountered after running "code.m".
Similarly the initial condition for "gr =0.0+0.0001*(1+sin(k*x))" which creates a 1x101 double vector.As seen from the above picture,we can see that error occured at line 115 which traces back to line 88.In line 88, the use of "gr(x)" is causing the issue, inorder to access a value of an array the index must be a positive integer.This condition is failed as the propogated "x" value in line 88 is not an integer.
In contrast, the initial condition "fr = @(x) 0.05 +0.0001*(1+sin(k*x))" creates a function handle. This code performs as anticipated, as the function handle operates effectively with both double and integer parameters in the provided code.

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by