error using multiplication, incorrect dimensions
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
James Tursa
2021년 2월 25일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!