Array multiplication in matlab

1 visualización (últimos 30 días)
Prajwal Kadlaplamutt Ravindra Kumar
Respondida: Star Strider el 9 de Mzo. de 2019
I have two set of text data. Lets say the size of first file is 26000*1 array and second file is 29000*1 array. I am looking to multiply the first element of 1st array with 1st element of 2nd array. How do i do that with different array sizes ? I dont mind if the extra 3000 rows of data are lost or ignored.

Respuestas (1)

Star Strider
Star Strider el 9 de Mzo. de 2019
One option:
V1 = rand(26000,1); % Create Data
V2 = rand(29000,1); % Create Data
V12 = V1 .* V2(1:numel(V1)); % Element-Wise Multiplication Of First 26000 Rows
Another option (if you do not want to discard the last 3000 rows) is to interpolate the larger vector to be the length of the shorter vector, using the interp1 funciton.

Categorías

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