Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Inner matrix dimensions must agree error?

조회 수: 1 (최근 30일)
D'Monte Pittman
D'Monte Pittman 2015년 2월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
I am trying to run these equations in the command window and I keep getting an Inner matrix dimensions must agree error.
I am new at matlab,I have no clue what I'm doing wrong. So far I have:
VN=12.00;
V=[12.0:24.0];
VC=V/VN;
TS=275;
T=linspace(0,235);
NNL=15700;
INL=0.3;
IS=4.09;
N=(VC.*NNL).*(1.-T)/(VC.*T);
I=VC.*INL+IS-INL*(T/TS);
P=1.635e-6.*(2.*pi)*(N.*T);
E=100.*P./(V.*I);

답변 (1개)

Geoff Hayes
Geoff Hayes 2015년 2월 15일
D'Monte - you are getting an error with
(VC.*T)
because VC is a 1x13 array and T is a 1x100 array so the code cannot do the element-wise multiplication because the two arrays are of different dimension (hence the error). Perhaps T should be defined as
T = linspace(0,235,length(V));
rather than using the default length of 100 (for linspace).
  댓글 수: 1
John D'Errico
John D'Errico 2015년 2월 15일
There would still be a problem. While I'm happy to see the .* operators used, D'Monte may not realize that there is also a ./ operator that must be employed here too, for the same reason.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by