Info

This question is closed. Reopen it to edit or answer.

Assigning values for vector with certain rule

2 views (last 30 days)
Ju Kim
Ju Kim on 15 Jun 2018
Closed: KSSV on 15 Jun 2018
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)

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!