How do I avoid using for loops in the following problem?

1 visualización (últimos 30 días)
Sicheng Zhang
Sicheng Zhang el 22 de Mzo. de 2018
Respondida: 埃博拉酱 el 28 de Oct. de 2024
B=[b1,b2,..,bn], C=[c1,c2,...,cn] , and D=[d1,d2,...,dn]|are known. A scalar |A(0) is also known. I need to calculate A(1)...A(n) using the following iteration: A(i)=max{ci,A(i-1)+bi}+di,i=1,...,n. Is there any method or function I can use to get A(1)...A(n) without using a for loop? Thank you in advance!

Respuestas (1)

埃博拉酱
埃博拉酱 el 28 de Oct. de 2024
迭代类问题通常都不能向量化,因为循环之间存在依赖关系。

Categorías

Más información sobre 循环及条件语句 en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!