??? Error using ==> mldivide Matrix dimensions must agree.
Afficher commentaires plus anciens
[EDIT: 20110621 11:43 CDT - reformat - WDR]
I have this error
??? Error using ==> mldivide
Matrix dimensions must agree.
however i can't find why it says 'cuz it's not a matrix it's a function...this is the code:
%--------------
k=1.7;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
t = 5:35;
Ec = nu*Eg(t-tp);
%graphe
plot(t,Ec)
------------------------------------
function y = Eg(t)
y = ilaplace(Egs(t),t,t);
------------------------------------
function y = Egs(s)
%constantes
a=14;
b=15;
c=25;
L=c-b;
r=c;
phi=15;
V=7*7*28;
ro=1000;
RHi=100;
RHb=50;
dRH = RHb-RHi;
nus=0.3;
D=1;
M=8.3*10^(-6);
k=1.7;
Es=200000;
nuc=0.2;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
%------------------------
D1 = s*Epssa(s)-(s+lambda)*Epssa(s+lambda)/exp(lambda*tp);
y = (1/k)*(a-b)*(a+b)*(Es/s)*D1*s*(b^2*(nuc-1)-c^2*(nuc+1))/(4*b^2*(s*Epsf(s)-(s+lambda)*Epsf(s+lambda))+(b-c)*(b+c)*D1*((a^2*(nus+1)-b^2*(nus-1))));
--------------------------------------------
function y = Epsf(s)
%constantes
a = 14;
b=15;
c=25;
L=c-b;
r=c;
phi=15;
V=7*7*28;
ro=1000;
RHi=100;
RHb=50;
dRH = RHb-RHi;
nus=0.3;
D=1;
M=8.3*10^(-6);
k=1.7;
Es=200000;
nuc=0.2;
lambda=0.3;
tp=1;
nu = k*(1-exp(-lambda*tp));
%-------------
%RH(c,s)
%Bi
B1 = b*sqrt(s)/sqrt(D);
B2 = c*sqrt(s)/sqrt(D);
B3 = r*sqrt(s)/sqrt(D);
B4 = -b*exp(B2)*(b-r)*(b+r)*RHi*sqrt(s)-3*c*exp(B2)*(b-r)*(b+r)*sqrt(s);
B5 = D^(7/4)*sqrt(pi)*dRH*(3*sqrt(D)-2*b*sqrt(s))*sqrt(-s/D)*(erf1(sqrt(b)*(s/D)^(1/4))-erf1(sqrt(r)*(s/D)^(1/4)))/(b^(3/2)*s^(9/4));
RH= sqrt(D)*exp(-c*sqrt(s)/sqrt(D))*(-b*c*s/D)^(3/2)*((D)^(3/2)*sqrt(-b*c*s/D)*(-6*c^(3/2)*(sqrt(6*D)*exp(B1)-exp(B3)*sqrt(D*r))*dRH-B4)/(b^2*c^2*s^2)+B5)/(2*(3*c+b)*s^(3/2));
y = -1.1*M*((c^2-b^2)*RHi/(2*s)-RH);
-----------------------------------------------
function ans = Epssa(s)
syms t;
Epsa = -16.7*10^(-6)*t^(0.3);
ans = laplace(Epsa,t,s);
-------------------------------------------
function ans=erfi1(t)
% %erfi(x). The Imaginary error function, as it is defined in Mathematica
% %erfi(z)==erf(iz)/i (z could be complex) using
% %the incomplete gamma function in matlab: gammainc
% %Using "@": erfi = @(x) real(-sqrt(-1).*sign(x).*gammainc(-x.^2,1/2))
% %Note: limit(x->0) erfi(x)/x -> 2/sqrt(pi)
%
% %Example 1:
% x=linspace(0.001,6,100);
% y=exp(-x.^2).*erfi(x)./2./x;
% figure(1), clf;plot(x,y*sqrt(pi))
%
% %Example 2:
% [x,y]=meshgrid(linspace(-3,3,180),linspace(-3,3,180));
% z=x+i*y;
% figure(1), clf;contourf(x,y,log(erfi(z)))
% axis equal;axis off
xc=5.7;%cut for asymptotic approximation (when x is real)
ans=~isreal(t).*(-(sqrt(-t.^2)./(t+isreal(t))).*gammainc(-t.^2,1/2))+...
isreal(t).*real(-sqrt(-1).*sign(t).*((t<xc).*gammainc(-t.^2,1/2))+...
(t>=xc).*exp(t.^2)./t/sqrt(pi));
-----------------------------------------------
function y = erfi(s)
%syms t;
%f = 2/sqrt(pi)*t+2/(3*sqrt(pi))*t^3+1/(5*sqrt(pi))*t^5+1/(21*sqrt(pi))*t^7+1/(108*sqrt(pi))*t^9+1/(660*sqrt(pi))*t^11+1/(4680*sqrt(pi))*t^13+1/(37800*sqrt(pi))*t^15;
y = laplace(erfi1(s),s,s);
-----------------------------------
please help :)
Réponses (4)
Sean de Wolski
le 21 Juin 2011
0 votes
What line does it say the error is on? I'll bet it's on that line where you do a left matrix division '/'.
Matt Tearle
le 21 Juin 2011
0 votes
Unless you actually want to do a matrix division, a simple solution is to do a find-n-replace: "/" -> "./"
Otherwise, please format your code and, as Sean says, show which line the error occurs on. For extra credit, you could put a breakpoint on that line, run the code again and do whos at the prompt when it stops on the error line.
Mohamed Yassin OUKILA
le 21 Juin 2011
0 votes
Mohamed Yassin OUKILA
le 21 Juin 2011
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!