Error in MuPAD command: The dimensions do not match
1 view (last 30 days)
Show older comments
Hi, I have to do a for cicle in which one variable (k) change and the others variables are costants, but Matlab gives me an error: Error in MuPAD command: The dimensions do not match. I am trying to use the following code (I'm sorry for the length of the equation) to obtain a vectors of results. Then I want to plot KAP as function of k:
syms F x c k
KAP=(F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k^2*exp(-k*(F + c - x))*(F*exp(-x) - 1) - F*exp(-k*(F + c - x))*exp(-x) + 2*F*k*exp(-k*(F + c - x))*exp(-x) + F*k^2*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1)^2 + 2*F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))/(k*exp(-k*(F + c - x))*(F*exp(-x) - 1) + F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - F*exp(-k*(F + c - x))*exp(-x) + F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))
k=0.1:0.1:0.6
for i=1:length(k)
KAP=(F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k^2*exp(-k*(F + c - x))*(F*exp(-x) - 1) - F*exp(-k*(F + c - x))*exp(-x) + 2*F*k*exp(-k*(F + c - x))*exp(-x) + F*k^2*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1)^2 + 2*F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))/(k*exp(-k*(F + c - x))*(F*exp(-x) - 1) + F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - F*exp(-k*(F + c - x))*exp(-x) + F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))
KAP=subs(KAP,{F,x,c,k(i)},{5,4,4,0.1})
KAP=vpa(KAP)
end
Variables like F, x, c have to be constant. Anyone could help me?
0 Comments
Answers (3)
Walter Roberson
on 20 Jul 2015
syms F x c k
KAPeqn = (F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k^2*exp(-k*(F + c - x))*(F*exp(-x) - 1) - F*exp(-k*(F + c - x))*exp(-x) + 2*F*k*exp(-k*(F + c - x))*exp(-x) + F*k^2*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1)^2 + 2*F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))/(k*exp(-k*(F + c - x))*(F*exp(-x) - 1) + F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - F*exp(-k*(F + c - x))*exp(-x) + F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1));
kvals = 0.1:0.1:0.6;
for i = 1 : length(kvals)
KAP(i) = vpa(subs(KAPeqn,{F,x,c,k},{5,4,4,kvals(i)}));
end
plot(kvals, KAP);
0 Comments
PIERLUIGI PEDERZOLI
on 20 Jul 2015
1 Comment
Walter Roberson
on 20 Jul 2015
syms F x c k
KAPeqn = (F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - k^2*exp(-k*(F + c - x))*(F*exp(-x) - 1) - F*exp(-k*(F + c - x))*exp(-x) + 2*F*k*exp(-k*(F + c - x))*exp(-x) + F*k^2*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1)^2 + 2*F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1))/(k*exp(-k*(F + c - x))*(F*exp(-x) - 1) + F*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F)) - F*exp(-k*(F + c - x))*exp(-x) + F*k*exp(-x)*exp(-k*(F + c - x - (exp(F) - exp(x))/F))*(exp(x)/F - 1));
kvals = 0.1:0.1:0.6;
for i = 1 : length(kvals)
KAPi = vpa(subs(KAPeqn,{F,x,c,k},{5,4,4,kvals(i)}))
KAP(i) = KAPi;
end
plot(kvals, KAP);
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!