フィルターのクリア

Index in position 1 is invalid. Array indices must be positive integers or logical values.

8 ビュー (過去 30 日間)
I got the problem that W is full of NaN's. Error is:
"Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in Seperationsansatz_2_lin_z (line 16) w(r,t) = W.*T;"
approach A*diff(w,r) + A*r*diff(w,r,r) -B*diff(w,t,t)
rspan = linspace(0,1);
W0 = [0; 1];
[r,W] = ode45(@odefct1,rspan, W0);
tspan = linspace(0,1);
T0 = [0;1];
[t,T] = ode45(@odefct2,tspan,T0);
w(r,t) = W.*T;
% plot(r,W(:,1),'-o',r,W(:,2),'-o')
% title('Solution');
% xlabel('Radius r');
% ylabel('Solution W');
% legend('W_1','W_2')
function dWdr = odefct1(r,W)
E = 70e7;
rho = 2.6989e-4;
ny = 0.34;
K = 1;
A = (0.5-ny);
B = rho*(1-2*ny)*(1+ny)/E;
dWdr = [ W(2); W(1)*(B*K)/A - W(2)/r];
end
function dTdt = odefct2(t,T)
K = 1;
dTdt = [T(2); K*T(1)];
end

採用された回答

KSSV
KSSV 2018 年 7 月 2 日
This line:
w(r,t) = W.*T;
Replace with:
w = W.*T;
  2 件のコメント
Dinglie Pang
Dinglie Pang 2020 年 12 月 18 日
Thanks! It works for my error like this! Btw, what's the theory behind it? I just unitentionally type it like "w(r,t)" and didn't see the difference was made, compared with "w"
KSSV
KSSV 2020 年 12 月 18 日
When you use w(r,t).. it means w is an array an you are trying to extract indices r,t. To do this your r, t should be positive integers or logical indices. But this is not the case in present. r, t are not indices, so error. You are not supposed to use w(r,t) here.

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

その他の回答 (1 件)

Abhinav chhabra
Abhinav chhabra 2021 年 10 月 25 日
Close matlab and start again. Its weird but worked for me!
all the best

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by