Array indices must be positive integers or logical values

I'm trying to solve for the variable T, but MATLAB is returning
Array indices must be positive integers or logical values.
Error in untitled (line 23)
Temp = ((T - Te)./(Tb - Te) == ((cosh(B(L - x))) + (Hc)/((B.*k).* ...
Here is the code:
%Question 9
syms Temp solx T Tb Te L D P Ac k Hc B x;
%Variables
Tb = 200;
Te = 20;
L = 8 * .01;
D = 5 * .001;
%B variables
P = (pi * D);
Ac = (pi * D.^2)/4;
k = 200;
Hc = 200;
%B equation
B = (Hc * P)/(k * Ac);
%input variable
x = 2 * .01;
%Equation
Temp = ((T - Te)./(Tb - Te) == ((cosh(B(L - x))) + (Hc)/((B.*k).* ...
sinh(B(L - x))))./((cosh(B.*L) + (Hc))./((B*k).*sinh(B.*L))));
%solve
solx = solve(Temp, T);
How can I fix this error?

 採用された回答

Voss
Voss 2023 年 1 月 15 日

0 投票

You probably mean
B.*(L - x)
instead of
B(L-x)
in two places.

その他の回答 (1 件)

the cyclist
the cyclist 2023 年 1 月 15 日

1 投票

I'm guessing that when you wrote
B(L - x)
(in two places), you intended this multiplication:
B.*(L - x)
instead. The way your wrote it, you are trying to index the (L-x)th element of B (which is why you got the error).

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

リリース

R2022b

質問済み:

2023 年 1 月 15 日

コメント済み:

2023 年 1 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by