Multiplying an entire table by a column from another table.

11 visualizaciones (últimos 30 días)
I want to take my a table of "data" and multiply it by a specific column from another table to result in "processed data". I have tried different multipication functions but I am always given the error "Undefined operator '.*' for input arguments of type 'table'." Is there a specific function that I am unaware of? I am running Matlab R2019a. Thank you.

Respuesta aceptada

Star Strider
Star Strider el 10 de Mzo. de 2020
Use the varfun function.
Example —
T = array2table(randi(99, 7, 5));
V = randi(99, 7, 1);
TV = varfun(@(x)x.*V, T);
  2 comentarios
Craig Stevens
Craig Stevens el 10 de Mzo. de 2020
Awesome, thank you for your quick assistance!
Star Strider
Star Strider el 10 de Mzo. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Bhaskar R
Bhaskar R el 10 de Mzo. de 2020
t1 = table;
t2 = table;
% table t1
t1.a = rand(10,1);
t1.b = rand(10,1);
% table t2
t2.c = rand(10, 1);
%processed_data
processed_data = t1.a.*t2.c;
% or if you want to embed in table
t1.processed_data = t1.a.*t2.c;

Categorías

Más información sobre Logical 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