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

3 ビュー (過去 30 日間)
lulu
lulu 2022 年 10 月 31 日
回答済み: SAI SRUJAN 2023 年 10 月 4 日
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 Center および File ExchangeData Type Identification についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by