How do I create an array of a function output?
Mostrar comentarios más antiguos
How do I create an array of a function output? Each attempt I've tried it overwrites the value in the array and returns a 1x1 array with the final value calculated as it's value.
I've seen nested list functions or push functions? Which is the best for the below case and how do I implement it?
Apologies if this is a simplistic question, just struggling with this problem.
My function is:
>> m=0:1:3
>> n=0:1:4
>> for a=m
for b=n
res=ack(a,b)
end
end
function res=ack(m,n)
if m==0
res = n+1;
elseif m>0 && n==0
res = ack(m-1,1);
elseif m>0 && n>0
res = ack(m-1,ack(m,n-1));
end
end
1 comentario
David Fletcher
el 25 de Feb. de 2018
Editada: Stephen23
el 26 de Feb. de 2018
Essentially your problem is very similar to the answer I provided for
Maybe not the 'best' way to do it, but it is pretty much the answer to the problem you are outlining
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 25 de Feb. de 2018
0 votos
1 comentario
FortuitousMonkey
el 26 de Feb. de 2018
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!