How can you convert an array into multiple inputs?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daniel
am 10 Dez. 2014
Beantwortet: Azzi Abdelmalek
am 10 Dez. 2014
I've been wondering about this for some time. Suppose I have a 2 x 4 array of integers, where each column should be a separate input for a function. I know the exact # of outputs of the output array (16 x 4 for this case) Is there a way to force a function to treat them as separate inputs without modifying the function line directly?
If this is possible, is it also possible to do the same for outputs?
The function I'm using is ngrid.
2 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 10 Dez. 2014
A= [-1 1; -2 2; -3 3; -4 4]'
b=cell(1,size(A,2))
c=num2cell(A,1)
[b{:}]=ndgrid(c{:})
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!