loop and mixing solution
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
KSSV
2020-7-27
A = 0:10:100 ;
B = A ;
C = A ;
[A,B,C] = meshgrid(A,B,C) ;
% convert them to columns
A = A(:) ; B = B(:) ; C = C(:) ;
% get the sum
thesum = A(:)+B(:)+C(:) ;
% get the indices whos sum isequal to 100
idx = thesum==100 ;
% pick the values
A = A(idx) ; B = B(idx) ; C = C(idx) ;
% ge the required Z
Z = 0.1*A+0.2*B+0.3*C ;
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!