Convert loop to vectorization
Mostra commenti meno recenti
Here is simple code where I would like to remove for loop. A=[9;9;9]; c1=[2;3;5] for i=1:length(c1) c=c1(i,1); [B]=Subsum (A,c) i=i+1; end
Function subsum is defined as below
function [B] = Subsum (A,c) B=A-c; end
Desired output First loop B=[ 7 ;7;7] second loop B=[6;6;6] and Third loop B=[4;4;4]
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements 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!