Similar to Binary search, I need a Decomposition method like it is described below.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Prasanna Venkatesh
el 29 de Ag. de 2019
Respondida: Naveen Venkata Krishnan
el 10 de Oct. de 2019
I have an array 'x'. Eg:
x = 1:15;
The values in x is used from start to end by other function (function1) linearly. function2 returns logical value. Eg:
function flag = mainfunction(x)
for idx =1:length(x)
y = function1(x(idx));
if function2(y)
flag = false;
return
end
end
flag = true;
end
Instead of using the values of x from start to end (idx = 1:15 - linear), i need to use it as in binary search but with a difference (Other half should not be rejected). Like the image below,
Now, 'idx' should be in this flow, idx = [8,4,12,2,6,10,14,1,3,4,7,9,11,13,15] till it enters the inside if statement
Can anyone help me out?
Thanks in advance!
0 comentarios
Respuestas (1)
Naveen Venkata Krishnan
el 10 de Oct. de 2019
Hello,
If you want idx to follow a particular flow you can directly give it as follows
for idx = [8,4,12,2,6,10,14,1,3,4,7,9,11,13,15]
What does the "till it enters the inside if " means ? Is it like idx should change the flow after the flag becomes false ?
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!