Error: Inner Matrix Dimension Must Agree

1 visualización (últimos 30 días)
nand  patel
nand patel el 16 de En. de 2020
Comentada: David Hill el 16 de En. de 2020
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 ?

Respuesta aceptada

David Hill
David Hill el 16 de En. de 2020
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 comentarios
nand  patel
nand patel el 16 de En. de 2020
can you please explain me why we are using (.*) instead of (*) to overcome this error
Thanks.
David Hill
David Hill el 16 de En. de 2020
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;

Iniciar sesión para comentar.

Más respuestas (1)

Stijn Haenen
Stijn Haenen el 16 de En. de 2020
you should use " .* " instead of " * " .

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by