Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Assigning values for vector with certain rule
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!