Effacer les filtres
Effacer les filtres

For loop code/ help

1 vue (au cours des 30 derniers jours)
Amine Ben Ayara
Amine Ben Ayara le 19 Août 2015
Hello Matlab wizards, So I just finished my 10th attempt at writing a code using for loops. The output was correct. MY issue is that I'm not being successful at adding one more loop that will allow matlab to rerun the same simulation 10 times, so I can get 90 matrices (3*3 each) and 10 matrices (9*3) in the end results. here is my code:
function [ MN ] = ProbabiltyMatrices( X,Lam,Y)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
for i=1:9
for l=1:3
for j=1:3
Den(i,l,n)=exp (Y(i+1,l)* dot(X(i,:),Lam(1,:))) + exp(Y(i+1,l)* dot(X(i,:),Lam(2,:))) +exp(Y(i+1,l)* dot(X(i,:),Lam(3,:)));
MN(l,j,i,n) = exp(Y(i+1,l)* dot(X(i,:),Lam(j,:)))/Den(i,l,n);
end
end
end
Ml =transpose(transpose(MN(:,:,1))* transpose(Y(2,:)));
for i=2:9
Ml(i,:)=transpose(transpose(MN(:,:,i))* transpose(Ml(i-1,:)));
end
M=Ml;
Would someone please help! Thanks

Réponses (1)

Walter Roberson
Walter Roberson le 19 Août 2015

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by