フィルターのクリア

I am trying to execute the code written below and getting the error given below, help me to fix this error?

1 回表示 (過去 30 日間)
The following error occurred converting from sym to double: Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in ExampleLoop (line 13) h(i,j) = 10*(((t(i,j)-.1)/.4)^-0.5-1)^.5;
code: clc; clear all; close all;
t = zeros(100,48); t(1,:) = .5;
t(:,1) = 0;
d = zeros(100,48);
k = zeros(100,48);
h = zeros(100,48);
syms t(i,j);
h(i,j) = 10*(((t(i,j)-.1)/.4)^-0.5-1)^.5;
k(i,j) = 10^-8*(t(i,j)-.1)/(.4)*(1-(1-((t(i,j)-.1)/0.4)^2)^.5)^2;
dh_dt(i,j) = diff(h(i,j));
dk_dt(i,j) = diff(k(i,j));
c(i,j) = 1/(dh_dt(i,j));
d(i,j) = k(i,j)/c(i,j);
dd_dt(i,j) = diff(c(i,j));
for i=2:99;
for j=1:47;
a = (1-.5*d(i,j)-.5*d(i+1,j));
b = .5*d(i,j);
c = .5*d(i+1,j);
t(i,j+1) = a*t(i,j)+b*t(i-1,j)+c*t(i+1,j)+.5*(k(i+1,j)-k(i-1,j));
end
end

採用された回答

Star Strider
Star Strider 2014 年 4 月 30 日
There are a few things wrong that I can see:
Do not use the ‘syms’ statement. You don’t need it. Use nested for loops for ‘i’ and ‘j’ instead.
In this and other statements like it:
dh_dt(i,j) = diff(h(i,j));
you are taking the difference of a single scalar element. That is not possible. (This would not have worked as a symbolic either, because your h matrix was not created as a function of a symbolic variable.)
What do you want to do in your code?
  8 件のコメント
Abhinav
Abhinav 2014 年 5 月 2 日
Thank you, that was very helpful.
Star Strider
Star Strider 2014 年 5 月 2 日
My pleasure!
Apologise for the delay — GMT-6 hours here.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApplications についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by