How do I create an array of a function output?
Mostra commenti meno recenti
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 Commento
David Fletcher
il 25 Feb 2018
Modificato: Stephen23
il 26 Feb 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
Risposta accettata
Più risposte (1)
Walter Roberson
il 25 Feb 2018
0 voti
1 Commento
FortuitousMonkey
il 26 Feb 2018
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!