changing a loop to a function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
AA
il 21 Dic 2014
Modificato: Azzi Abdelmalek
il 21 Dic 2014
for x = 1:100
for y = 1:61
b = abs(bsxfun(@minus,q{x},kevin))
s{x,y} = b;
end
end
How do I incorporate the above code as function?
the variables kevin and q are already loaded on the workspace.
thanks
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 21 Dic 2014
Modificato: Azzi Abdelmalek
il 21 Dic 2014
function s=yourfunction(q,kevin)
for x = 1:100
for y = 1:61
b = abs(bsxfun(@minus,q{x},kevin))
s{x,y} = b;
end
end
save this file as yourfunction.m
To call this function
q= % assign value to q
kevin= % assign value to kevin
s=yourfunction(q,kevin)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements 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!