why estimating 3 values takes longer time than estimating 4 values?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sadiq Akbar
am 12 Feb. 2023
Kommentiert: Sadiq Akbar
am 14 Feb. 2023
In the attached code, when we estimate 2 values of u, it takes less time than the case where we estimate 3 values of u? It seems ok. But its strange that when we look at the time for estimating 3 values of u, it takes more time than estimating 4 values of u. Why it is so?
3 Kommentare
Akzeptierte Antwort
Anton Kogios
am 14 Feb. 2023
I am not exactly an 'expert', but the times I get depend on:
- the order that you run them (like 3, then 2, then 1). From my basic understanding, you get different results based on the order due to how things run on processors (I think?).
- more probably, the mean of u. I am not exactly sure about the aim of your code/what it is doing, but values of u with an even number of elements and a mean of 0 perform faster than values of u with one less element and a mean not equal to 0.
I modified your original main1TimeComparing.m to a new one (attached to post). It loops 20 times per length of u and also tests lengths of 5 and 6. I got the following results after running it twice on a M1 Pro MacBook Pro with the R2022b Apple Silicon Beta:
- Run 1: [5.3750 6.1739 6.0049 6.6926 6.3277]
- Run 2: [5.4516 6.2095 6.0587 6.7427 6.3106]
Hope this points you in the right direction since you know what your code is doing! In-built MATLAB functions have a lot of optimisations for vectors, and this may be a product of that.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!