implementation of a matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Franziska Bömann
le 19 Juil 2020
Modifié(e) : madhan ravi
le 19 Juil 2020
Hello! I want to implement the following matrix:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334089/image.png)
where
is a given vector of random indices
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334092/image.png)
Can someone help me to implement that?
3 commentaires
Réponse acceptée
Thiago Henrique Gomes Lobato
le 19 Juil 2020
This should do:
rng(42)
n = 3;
x = rand(n,1);
A = ones(n,n+1);
Differences = x-x';
for idx=2:n+1
A(:,idx) = A(:,idx-1).*Differences(:,idx-1);
end
x
A
x =
0.3745
0.9507
0.7320
A =
1.0000 0 0 0
1.0000 0.5762 0 0
1.0000 0.3575 -0.0782 0
Plus de réponses (1)
Bruno Luong
le 19 Juil 2020
Modifié(e) : Bruno Luong
le 19 Juil 2020
n = 3;
x = rand(n+1,1);
A = cumprod([ones(size(x)), (x-x(1:end-1).')], 2)
1 commentaire
madhan ravi
le 19 Juil 2020
Modifié(e) : madhan ravi
le 19 Juil 2020
But why though? It’s pretty obvious it’s a homework question? It’s not a homework solving contest XD.
Voir également
Catégories
En savoir plus sur Calendar dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!