For loop code/ help

1 次查看(过去 30 天)
Amine Ben Ayara
Amine Ben Ayara 2015-8-19
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

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-19

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by