I am trying to execute the code written below and getting the error given below, help me to fix this error?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Star Strider
le 30 Avr 2014
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Boundary Conditions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!