Array multiplication in matlab
显示 更早的评论
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.
回答(1 个)
Star Strider
2019-3-9
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!