필터 지우기
필터 지우기

how can I do this fast addition and multiplication?

조회 수: 1 (최근 30일)
Kate
Kate 2014년 8월 6일
편집: Kate 2014년 8월 6일
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

채택된 답변

Michael Haderlein
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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by