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

3 Ansichten (letzte 30 Tage)
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.

Antworten (1)

SAI SRUJAN
SAI SRUJAN am 4 Okt. 2023
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.

Kategorien

Mehr zu Data Type Identification finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by