How do I create an array of a function output?
Ältere Kommentare anzeigen
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 Kommentar
David Fletcher
am 25 Feb. 2018
Bearbeitet: Stephen23
am 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
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 25 Feb. 2018
0 Stimmen
1 Kommentar
FortuitousMonkey
am 26 Feb. 2018
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!