Info
此问题已关闭。 请重新打开它进行编辑或回答。
Assigning values for vector with certain rule
3 次查看(过去 30 天)
显示 更早的评论
n - number that I should assign firstly. Any integer from 1 to infinity. you can limit the upper limit of n for convenience. m = (n^2 + 3n)/2; r1 - should be assigned firstly; r2 - should be assigned firstly;
vector p has m number of members i.e) p=[1:1:m];
And there is a rule like this. example) for n=1 --> p(1)= r1, p(2)= r2 for n=2 --> p(1)= r1, p(2)= r2, p(3)= r1+r1, p(4) = r1+r2, p(5)= r2+r2 for n=3 --> p(1)= r1, p(2)= r2, p(3)= r1+r1, p(4) = r1+r2, p(5)= r2+r2, p(6)= r1+r1+r1, p(7)=r1+r1+r2, p(8)= r1+r2+r2, p(9)=r2+r2+r2 ... and so on
How can I make this p vector ? (Actually the order of members of p vector can be changed as long as p contains all members for its n and m. like p(1)=r1, p(2)=r1+r1, p(3)=r1+r1+r1, p(4)=r2, p(5)=r1+r2, ..... p(m)= r2+r2+r2+....+r2)
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!