Azzera filtri
Azzera filtri

For loop code/ help

1 visualizzazione (ultimi 30 giorni)
Amine Ben Ayara
Amine Ben Ayara il 19 Ago 2015
Risposto: Walter Roberson il 19 Ago 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

Risposte (1)

Walter Roberson
Walter Roberson il 19 Ago 2015

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by