How can I rectify the parse error at '=' in line 7?

1 回表示 (過去 30 日間)
KAKARLA SATYA VEERA VENKATA SIVA RAMAKRISHNA
コメント済み: Walter Roberson 2020 年 3 月 5 日
function ethylene
T = 306; % Temperature in K
P = 13.5; % Pressure in bar
R = 0.0831; % Gas constant in L*bar*K^-1
B = -140000; % B in L*(mol)^-1
C = 7200000; % C in L^2*(mol)^-2
1+(B/V)+(C/V^2) = P*V/R/T; % Volume in L
fprintf('The volume of ethylene is %d L\n',V)
end
  1 件のコメント
KSSV
KSSV 2020 年 3 月 5 日
What is this line?
1+(B/V)+(C/V^2) = P*V/R/T; % Volume in L

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

回答 (1 件)

Jonas Allgeier
Jonas Allgeier 2020 年 3 月 5 日
編集済み: Jonas Allgeier 2020 年 3 月 5 日
In line eight, you want to print the value of V. The problem is, you never assign it any value. Variable assigment in essence always requires a line like
V = ...
In your code however, you seem to provide an equation that could be solved for V. This is no direct assignment and Matlab therefore does not know what to do with this line.
To rectify this error, you would need to have an equation that already is solved for V. Otherwise you could also use some kind of optimization technique to find the solution of this equation by iteratively testing different values until the equation is (nearly) met.
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 5 日
fsolve() an expression which is the left side minus the right side

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

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by