is it possible to pass an array into a function?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
is it possible to pass an array into a function?
1 Commento
Stephen23
il 25 Apr 2015
Yes, because all variables are arrays in MATLAB: even scalar values are just 1x1 arrays, so there is absolutely no difference in how they get passed to functions. The only difference is if the function algorithm is written to work with them!
Risposta accettata
Star Strider
il 25 Apr 2015
Yes. The array is a variable, the same as a scalar, so you would simply pass it by its variable name as part of the argument list.
Example:
mtx_vct_prod = @(M,v) M*v(:);
M = rand(4); % (4x4) Matrix
v = rand(4,1); % (4x1) Vector
Mv = mtx_vct_prod(M,v);
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!