Using data from table in calculations

20 views (last 30 days)
Stephen Fleming
Stephen Fleming on 2 Feb 2021
Commented: Stephen Fleming on 2 Feb 2021
I have recently started using MATLAB and have a basic understanding of it. I have a table with 99000 rows (these rows are values at particular times) in it and want to perform the same calculation on each row giving an output, then moving to the next row, perform the calculation and so on.
I can perform the calculation by manually entering the numbers but want my script to be able to get the values itself. I have tried calling the input columns like:
and they do give out an array. But then I get an error when it tries to put X, Y & Z through the calculation. Is there a certain loop I need to do to go through this in iterations?
(p.s, I have searched online and on the Using Tables section of MATLAB help but to no avail.)
Any help is appreciated
Stephen Fleming
Stephen Fleming on 2 Feb 2021
Hi, thanks for replying!
So I am combining the value with another vector. Each of my values has a corresponding angle in the same row in the tabel. I am then combining these to get them into cartesian form (splitting real and imaginary parts) to be able to perform calculations with them.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 2 Feb 2021
Have you tried a simple loop like this?
% Function returns a scalar value and stores it in a vector.
% Function contains 3 inputs.
out = zeros(1, height(TableName)); % preallocate; assuming a vector
for i = 1:height(TableName)
out(i) = fun(TableName.Col1(i), TableName.Col2(i), TableName.Col3(i));




Community Treasure Hunt

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

Start Hunting!

Translated by