error using multiplication, incorrect dimensions
3 views (last 30 days)
Show older comments
I get an error that says error using * in lines 18 and 19, I can't quite seem to figure out where the correction is to be! anything helps! thanks
delta = 0.05;
p = 0.85;
v = 0.05;
y = [0 0.50 2.5];
u = 0.02;
I = 6000000;
t = [0 10 100];
c0 = 95000000;
n0 = 112000000;
e = 1;
theta = y + u + v + delta;
s = p + theta + u;
b = p*v + p*delta + p*u + u*theta;
a = 2*p + u;
n1 = 1/2*(s - sqrt(s.^2 - 4*b));
n2 = 1/2*(s + sqrt(s.^2 - 4*b));
k1 = ((b*(p+theta-n2)*c0+I*(a*n2-b)-(p*b*n0))/(b*(n1-n2)));
k2 = ((-b*(p+theta-n1)*c0+I*(b-a*n2)-(p*b*n0))/(b*(n1-n2)));
c_t = k1*e.^(-n1*t) + k2*e.^(-n2*t)+(a/b)*I;
plot (t, c_t);
0 Comments
Answers (1)
James Tursa
on 25 Feb 2021
There are vectors in those equations, so maybe you just need to use element-wise operations:
k1 = ((b.*(p+theta-n2).*c0+I.*(a.*n2-b)-(p.*b.*n0))./(b.*(n1-n2)));
k2 = ((-b.*(p+theta-n1).*c0+I.*(b-a.*n2)-(p.*b.*n0))./(b.*(n1-n2)));
0 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!