set a if loop within a for loop
古いコメントを表示
hi
I want to set an if loop within for loops
My idea is if the constraint satified then stop the for (j) loop and profit (i,j) does not exist; otherwise continue the loop and find the solution
but my code doesnt work well: it cannot stop the for loop when the if loop is satisfied
for i=1:numel(k)
for j=1:numel(lambda)
if lambda(j)/(mu*k(i)) >= 1
return
else
n = (0:(k(i)-1));
W = 1/(sum((a).^n./factorial(n))+a^k(i)/(factorial(k(i))*(1-a/k(i))));
profit(i,j) = lambda(j)*(p-w);
end
end
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!