how can I do this fast addition and multiplication?

1 view (last 30 days)
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]
% 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

Accepted Answer

Michael Haderlein
Michael Haderlein on 6 Aug 2014
can replace your loop and should be faster than your solution.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!