multiply table and matrix

17 vues (au cours des 30 derniers jours)
Mo Das
Mo Das le 23 Mai 2019
Commenté : Mo Das le 23 Mai 2019
how can i multiply these example?
A= {[0.2 0.5 0.3] [ 0.1 0.1 0.3]}
A=cell2table(A)
B=[ 2 3]
A*B must be {[0.4 1 0.6] [0.3 0.3 0.9]}

Réponse acceptée

madhan ravi
madhan ravi le 23 Mai 2019
Modifié(e) : madhan ravi le 23 Mai 2019
I prefer Adam's method :
although if you want to multiply table with matrix then=>
arrayfun(@(x) A{:,x}*B(x),1:numel(B),'un',0)

Plus de réponses (1)

Adam
Adam le 23 Mai 2019
Why all the complications with cell arrays and tables? Just use numeric arrays:
A = [0.2 0.5 0.3; 0.1 0.1 0.3];
B = [2;3];
C = A.* B;
or
C = bsxfun( @times, A, B );
if you have an older version of Matlab.
  1 commentaire
Mo Das
Mo Das le 23 Mai 2019
i need to get answer like this {[0.4 1 0.6] [0.3 0.3 0.9]}
but matrix gives me
[0.4 1 0.6
0.3 0.3 0.9]
in first situation i have 2 items and i need 2 items too but in second form i get 6 ones

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by