Input of Rows for functions

Hello;
I have a file of production scheudules. I want to use each row as an input to function, rather than using loops for time saving.
Would you please help how I can manage it? The input is the B(j , :) jth row(as I used loop in the past)
++
bruteForceResults(:, 2) = calculateMaxTardinessWithSequence(B(j,:), processingTimes, dueTimes, sequenceDependentSetupTimes, numMachines);
++
Thanks in advance.

4 comentarios

Jonas
Jonas el 11 de Mzo. de 2024
Editada: Jonas el 11 de Mzo. de 2024
there are many matlab function which can work on multiple columns at once instead of one only. e.g. instead of caling max() on each column of a matrix, you can call it once for the whole matrix. if your data is managed in rows at the moment, just transpose them and go trough your code of your funtion and check if it can operate on multiple columns at the same time
and alternative approach can be to use parfor instead of the for loop
Dyuman Joshi
Dyuman Joshi el 11 de Mzo. de 2024
Editada: Dyuman Joshi el 11 de Mzo. de 2024
"I want to use each row as an input to function, rather than using loops for time saving."
In most cases, a (well written) for loop (e.g with preallocation) will be faster than any function doing the same thing.
Depending upon what operations you are performing, you could vectorize your code - Vectorization.
Without the code, it is difficult to comment on/suggest which approach will work best for you.
Fatih
Fatih el 12 de Mzo. de 2024
thanks a lot for the feedbacks. I will revise my code accordingly. Thanks
Dyuman Joshi
Dyuman Joshi el 15 de Mzo. de 2024
Any updates, @Fatih?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Mzo. de 2024

Comentada:

el 15 de Mzo. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by