How can i speed up my function?
2 views (last 30 days)
I'm trying to increase the performance of my Matlab function. Input is a table with the same columns as airfoil_update.
The function splits the X-Coordinates of one AeroDataId at the minimum of X/C and does this for every AeroDataId in the table. Airfoil, the input table, will have a size of 131123421x4. But the fourth column "Upper" is empty and should be filled up with a 1, if the coordinate belongs to the upper airfoil and 0, if it belongs to the lower airfoil.
Thank you very much in advance.
function [airfoil_update] = splitAirfoil(airfoil)
%% create table for upper and lower airfoil
%% vector with unique AeroDataIds
%% temp vector filled with every point of specific AeroDataId
%% find the minimum of X/C
%% every point with same ID before minimum -> lower_airfoil -> Upper =0
%% every point with same ID after minimum = upper_airfoil -> Upper =1
%% add new rows
Philippe Lebel on 8 Jan 2020
Edited: Philippe Lebel on 8 Jan 2020
In order to help you in a significant way, it would be useful to have a sample data set on which we could run the function.
On the top of my head, i'd remove the disp() function call. Printing info to the console takes a significant amount of time for no real benefit.
I would also pre-alocate the size of
since you know it's maximum size, you can pre alocate it to that size and keep track of the number of elements you put in it then chop the unused space only once at the end of the script.