필터 지우기
필터 지우기

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by