clc
clear all
Vd = 0:0.1:0.7
P = ((0.6*Vd)-((Vd*1.5*10^-12)*(exp(38.64*Vd)-1)))
plot(Vd,P)
when i run this code itgives me error : Inner Matrix Dimension Must Agree ?
What changes should i do to get my code correct ?

 채택된 답변

David Hill
David Hill 2020년 1월 16일

1 개 추천

Vd = 0:0.1:0.7;
P = ((0.6*Vd)-((Vd*1.5*10^-12).*(exp(38.64*Vd)-1)));%just need a dot (.*)
plot(Vd,P)

댓글 수: 2

nand  patel
nand patel 2020년 1월 16일
can you please explain me why we are using (.*) instead of (*) to overcome this error
Thanks.
scarlar * matrix/vector ok to use *, but matrix * matrix (same size) must use .* for element-wise multiplication (* is reserved for matrix multiplication).
element-wise
1./matrix;
Matrix.*matrix;
matrix.^2;
2.^matrix;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stijn Haenen
Stijn Haenen 2020년 1월 16일

1 개 추천

you should use " .* " instead of " * " .

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2020년 1월 16일

댓글:

2020년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by