problem with symbolic calculation

1 回表示 (過去 30 日間)
YOGESHWARI PATEL
YOGESHWARI PATEL 2021 年 3 月 14 日
コメント済み: YOGESHWARI PATEL 2021 年 3 月 17 日
I want symbolic calculation .I write the code but error is displayed
syms a
syms R
n=input('enter the value of n')
F(1)=1;
F(2)=0;
F(3)= a;
aplha=input('enter the value of a=')
R=input('enter the value of reynold number R=')
for i=1:n
F(i+3)=2*alpha*R*F(i)+F(i+1);
end

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 16 日
編集済み: Walter Roberson 2021 年 3 月 16 日
aplha=input('enter the value of a=')
You assign to aplha . A. P. L. H. A
R=input('enter the value of reynold number R=')
for i=1:n
F(i+3)=2*alpha*R*F(i)+F(i+1);
You use alpha . A. L. P. H. A.
You have not assigned to alpha.
alpha happens to exist as a function, but the function alpha requires that you pass a parameter to it, so you would get an error.
You need to change your input() to assign to alpha instead of aplha
  1 件のコメント
YOGESHWARI PATEL
YOGESHWARI PATEL 2021 年 3 月 17 日
Thank you

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2021 年 3 月 14 日
The way you've written it, when you try to assign a into F(3) MATLAB needs to convert the symbolic a into a numeric value so it can be stored in the numeric array F. But what is the numeric value of a? It doesn't have one, which is why MATLAB complains.
Since you want F to be able to store symbolic variables, don't initialize it to be a numeric array first. Initialize it as symbolic from the start by assigning a symbolic expression to it to create the array.
F(1) = sym(1);
Or since you know how large it will need to be in the end:
F = sym(zeros(1, n+3));
  1 件のコメント
YOGESHWARI PATEL
YOGESHWARI PATEL 2021 年 3 月 16 日
Thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by