how can I do this fast addition and multiplication?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I am transforming some data using an equation that involves a multiplication and addition. (Please see line 20 in the full code below this post., i.e. the following line:
newdata1 = (((R)*X1_full(:,i))+ T)';
In this example, I only have 4 data points (i.e. in the 'X1_full' variable). So speed is not a problem using the FOR loop. However, my actual dataset is very large (2 million data points). Any suggestion to improve the speed will be helpful.
cheers. K.
clc;clear all;close all
% input data to transform
X1_full = [1 2 3 5;
45 8 7 95;
12 78 98 3]
% R and T are transform params
T = [292.213040777858;78.1087497964877;865.7398878749]
R=[0.999998463087434,8.08983068375718e-05,-0.00175136467802407;
-8.44379283493625e-05,0.999997954040306,-0.00202108521267277;
0.00175119759243091,0.00202122998804671,0.999996423961770;]
% Loop through all data and transform
for i = 1:size(X1_full,2)
% Formula to transform the input data
newdata1 = (((R)*X1_full(:,i))+ T)';
Savenewdata1(i,:) = newdata1
end
0 件のコメント
採用された回答
Michael Haderlein
2014 年 8 月 6 日
Savenewdata1=bsxfun(@plus,(R*X1_full),T)';
can replace your loop and should be faster than your solution.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!