error using multiplication, incorrect dimensions

3 visualizaciones (últimos 30 días)
Karolina Nowobilska
Karolina Nowobilska el 25 de Feb. de 2021
Respondida: James Tursa el 25 de Feb. de 2021
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);

Respuestas (1)

James Tursa
James Tursa el 25 de Feb. de 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)));

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by