I have the following lines:
for x=1:800
for y=1:500
[mystruct(y).I] = ...
insideFunc( ...
mystruct(y).one(x),...
mystruct(y).two.pwr(x),...
mystruct(y).three.pwr(x),...
mystruct(y).four,...
mystruct(y).five,...
mystruct(y).six...
);
end
end
It seems most of the time of the simulation is spent on those line. My guess is that getting the values from the structure (to feed the function insideFunc) consumes a lot of time (once it gets inside InsideFunc, it executes relatively fast ). My question is: is there way to improve the code by changing the way to collect the input data for the function?
3 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_898080
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_898080
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_898083
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_898083
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_994301
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/548208-improve-use-of-structure-in-function#comment_994301
Sign in to comment.