Array multiplication in matlab
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Star Strider
on 9 Mar 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.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!