Effacer les filtres
Effacer les filtres

how to let elements in each column of a matrix divided by the first element in each column

2 vues (au cours des 30 derniers jours)
Chen
Chen le 4 Août 2018
Modifié(e) : dpb le 4 Août 2018
is there a simple way to let all the elements in a column of a matrix divided by the first element of each column, without using for loop?

Réponses (1)

dpb
dpb le 4 Août 2018
Modifié(e) : dpb le 4 Août 2018
x=x./x(1,:);
uses recent automagic(*) singleton expansion, if you have earlier release that errors on size mismatch then use bsxfun
x=bsxfun(@rdivide,x,x(1,:));
(*) I don't recall just when was introduced around R2015 or so...R2014b is earliest presently installed here --
>> x./x(1,:)
Error using ./
Matrix dimensions must agree.
>>

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by