How to find the scalar multiple of two vectors?

5 visualizaciones (últimos 30 días)
Mohammad Ezzad Hamdan
Mohammad Ezzad Hamdan el 18 de Mayo de 2018
Editada: James Tursa el 18 de Mayo de 2018
Example; a=[1;2;3] and b=[2;4;6], hence the lambda is 2.

Respuestas (1)

James Tursa
James Tursa el 18 de Mayo de 2018
Editada: James Tursa el 18 de Mayo de 2018
E.g., (with some accounting for potential 0 values)
d = b ./ a;
result = mean(d(~isnan(d)));
This is naive code that assumes the same scalar applies to all elements. If it is possible that is not the case, you would need to tell us how to handle the situation.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by