for a1=1:W
for a2=a1:W
for a3=a2:W
for a4=a3:W
for a5=i-a4-a3-a2-a1;
if(a4 <= a5 && a5<=W)
p2=[p2;a1,a2,a3,a4,a5];
end
end
end
end
end
end
Here if a1=1 then a2=1,2,3, if a1=2 then a2=2,3 and if a1=3 then a2=3. The same condition is for a3 & a4. Now I want to make this program only depends on "W" and "i" and I don't want to write a1,a2,a3,a4,a5.Because i need to run this code for i=4 and for a=2:4(a1 a2,a1 a2 a3,a1 a2 a3 a4)and again for i=5 and for a=2:4(a1 a2,a1 a2 a3,a1 a2 a3 a4,a1,a2,a3,a,a5).So i will be continue upto 17. and there are lot of values of "a".I just want to write "W,and i" and it will automatically generate value of "p2"
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment